39#ifndef INCLUDE_NLOHMANN_JSON_HPP_
40#define INCLUDE_NLOHMANN_JSON_HPP_
42#ifndef JSON_SKIP_LIBRARY_VERSION_CHECK
43 #if defined(NLOHMANN_JSON_VERSION_MAJOR) && defined(NLOHMANN_JSON_VERSION_MINOR) && defined(NLOHMANN_JSON_VERSION_PATCH)
44 #if NLOHMANN_JSON_VERSION_MAJOR != 3 || NLOHMANN_JSON_VERSION_MINOR != 10 || NLOHMANN_JSON_VERSION_PATCH != 5
45 #warning "Already included a different version of the library!"
50#define NLOHMANN_JSON_VERSION_MAJOR 3
51#define NLOHMANN_JSON_VERSION_MINOR 10
52#define NLOHMANN_JSON_VERSION_PATCH 5
57#include <initializer_list>
79#include <forward_list>
85#include <unordered_map>
167 static constexpr std::array<std::uint8_t, 9> order = {{
174 const auto l_index =
static_cast<std::size_t
>(lhs);
175 const auto r_index =
static_cast<std::size_t
>(rhs);
176 return l_index < order.size() && r_index < order.size() && order[l_index] < order[r_index];
203#if !defined(JSON_HEDLEY_VERSION) || (JSON_HEDLEY_VERSION < 15)
204#if defined(JSON_HEDLEY_VERSION)
205 #undef JSON_HEDLEY_VERSION
207#define JSON_HEDLEY_VERSION 15
209#if defined(JSON_HEDLEY_STRINGIFY_EX)
210 #undef JSON_HEDLEY_STRINGIFY_EX
212#define JSON_HEDLEY_STRINGIFY_EX(x) #x
214#if defined(JSON_HEDLEY_STRINGIFY)
215 #undef JSON_HEDLEY_STRINGIFY
217#define JSON_HEDLEY_STRINGIFY(x) JSON_HEDLEY_STRINGIFY_EX(x)
219#if defined(JSON_HEDLEY_CONCAT_EX)
220 #undef JSON_HEDLEY_CONCAT_EX
222#define JSON_HEDLEY_CONCAT_EX(a,b) a##b
224#if defined(JSON_HEDLEY_CONCAT)
225 #undef JSON_HEDLEY_CONCAT
227#define JSON_HEDLEY_CONCAT(a,b) JSON_HEDLEY_CONCAT_EX(a,b)
229#if defined(JSON_HEDLEY_CONCAT3_EX)
230 #undef JSON_HEDLEY_CONCAT3_EX
232#define JSON_HEDLEY_CONCAT3_EX(a,b,c) a##b##c
234#if defined(JSON_HEDLEY_CONCAT3)
235 #undef JSON_HEDLEY_CONCAT3
237#define JSON_HEDLEY_CONCAT3(a,b,c) JSON_HEDLEY_CONCAT3_EX(a,b,c)
239#if defined(JSON_HEDLEY_VERSION_ENCODE)
240 #undef JSON_HEDLEY_VERSION_ENCODE
242#define JSON_HEDLEY_VERSION_ENCODE(major,minor,revision) (((major) * 1000000) + ((minor) * 1000) + (revision))
244#if defined(JSON_HEDLEY_VERSION_DECODE_MAJOR)
245 #undef JSON_HEDLEY_VERSION_DECODE_MAJOR
247#define JSON_HEDLEY_VERSION_DECODE_MAJOR(version) ((version) / 1000000)
249#if defined(JSON_HEDLEY_VERSION_DECODE_MINOR)
250 #undef JSON_HEDLEY_VERSION_DECODE_MINOR
252#define JSON_HEDLEY_VERSION_DECODE_MINOR(version) (((version) % 1000000) / 1000)
254#if defined(JSON_HEDLEY_VERSION_DECODE_REVISION)
255 #undef JSON_HEDLEY_VERSION_DECODE_REVISION
257#define JSON_HEDLEY_VERSION_DECODE_REVISION(version) ((version) % 1000)
259#if defined(JSON_HEDLEY_GNUC_VERSION)
260 #undef JSON_HEDLEY_GNUC_VERSION
262#if defined(__GNUC__) && defined(__GNUC_PATCHLEVEL__)
263 #define JSON_HEDLEY_GNUC_VERSION JSON_HEDLEY_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__)
264#elif defined(__GNUC__)
265 #define JSON_HEDLEY_GNUC_VERSION JSON_HEDLEY_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, 0)
268#if defined(JSON_HEDLEY_GNUC_VERSION_CHECK)
269 #undef JSON_HEDLEY_GNUC_VERSION_CHECK
271#if defined(JSON_HEDLEY_GNUC_VERSION)
272 #define JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_GNUC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
274 #define JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) (0)
277#if defined(JSON_HEDLEY_MSVC_VERSION)
278 #undef JSON_HEDLEY_MSVC_VERSION
280#if defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 140000000) && !defined(__ICL)
281 #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 10000000, (_MSC_FULL_VER % 10000000) / 100000, (_MSC_FULL_VER % 100000) / 100)
282#elif defined(_MSC_FULL_VER) && !defined(__ICL)
283 #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 1000000, (_MSC_FULL_VER % 1000000) / 10000, (_MSC_FULL_VER % 10000) / 10)
284#elif defined(_MSC_VER) && !defined(__ICL)
285 #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_VER / 100, _MSC_VER % 100, 0)
288#if defined(JSON_HEDLEY_MSVC_VERSION_CHECK)
289 #undef JSON_HEDLEY_MSVC_VERSION_CHECK
291#if !defined(JSON_HEDLEY_MSVC_VERSION)
292 #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (0)
293#elif defined(_MSC_VER) && (_MSC_VER >= 1400)
294 #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_FULL_VER >= ((major * 10000000) + (minor * 100000) + (patch)))
295#elif defined(_MSC_VER) && (_MSC_VER >= 1200)
296 #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_FULL_VER >= ((major * 1000000) + (minor * 10000) + (patch)))
298 #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_VER >= ((major * 100) + (minor)))
301#if defined(JSON_HEDLEY_INTEL_VERSION)
302 #undef JSON_HEDLEY_INTEL_VERSION
304#if defined(__INTEL_COMPILER) && defined(__INTEL_COMPILER_UPDATE) && !defined(__ICL)
305 #define JSON_HEDLEY_INTEL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, __INTEL_COMPILER_UPDATE)
306#elif defined(__INTEL_COMPILER) && !defined(__ICL)
307 #define JSON_HEDLEY_INTEL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, 0)
310#if defined(JSON_HEDLEY_INTEL_VERSION_CHECK)
311 #undef JSON_HEDLEY_INTEL_VERSION_CHECK
313#if defined(JSON_HEDLEY_INTEL_VERSION)
314 #define JSON_HEDLEY_INTEL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_INTEL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
316 #define JSON_HEDLEY_INTEL_VERSION_CHECK(major,minor,patch) (0)
319#if defined(JSON_HEDLEY_INTEL_CL_VERSION)
320 #undef JSON_HEDLEY_INTEL_CL_VERSION
322#if defined(__INTEL_COMPILER) && defined(__INTEL_COMPILER_UPDATE) && defined(__ICL)
323 #define JSON_HEDLEY_INTEL_CL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER, __INTEL_COMPILER_UPDATE, 0)
326#if defined(JSON_HEDLEY_INTEL_CL_VERSION_CHECK)
327 #undef JSON_HEDLEY_INTEL_CL_VERSION_CHECK
329#if defined(JSON_HEDLEY_INTEL_CL_VERSION)
330 #define JSON_HEDLEY_INTEL_CL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_INTEL_CL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
332 #define JSON_HEDLEY_INTEL_CL_VERSION_CHECK(major,minor,patch) (0)
335#if defined(JSON_HEDLEY_PGI_VERSION)
336 #undef JSON_HEDLEY_PGI_VERSION
338#if defined(__PGI) && defined(__PGIC__) && defined(__PGIC_MINOR__) && defined(__PGIC_PATCHLEVEL__)
339 #define JSON_HEDLEY_PGI_VERSION JSON_HEDLEY_VERSION_ENCODE(__PGIC__, __PGIC_MINOR__, __PGIC_PATCHLEVEL__)
342#if defined(JSON_HEDLEY_PGI_VERSION_CHECK)
343 #undef JSON_HEDLEY_PGI_VERSION_CHECK
345#if defined(JSON_HEDLEY_PGI_VERSION)
346 #define JSON_HEDLEY_PGI_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_PGI_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
348 #define JSON_HEDLEY_PGI_VERSION_CHECK(major,minor,patch) (0)
351#if defined(JSON_HEDLEY_SUNPRO_VERSION)
352 #undef JSON_HEDLEY_SUNPRO_VERSION
354#if defined(__SUNPRO_C) && (__SUNPRO_C > 0x1000)
355 #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((((__SUNPRO_C >> 16) & 0xf) * 10) + ((__SUNPRO_C >> 12) & 0xf), (((__SUNPRO_C >> 8) & 0xf) * 10) + ((__SUNPRO_C >> 4) & 0xf), (__SUNPRO_C & 0xf) * 10)
356#elif defined(__SUNPRO_C)
357 #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((__SUNPRO_C >> 8) & 0xf, (__SUNPRO_C >> 4) & 0xf, (__SUNPRO_C) & 0xf)
358#elif defined(__SUNPRO_CC) && (__SUNPRO_CC > 0x1000)
359 #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((((__SUNPRO_CC >> 16) & 0xf) * 10) + ((__SUNPRO_CC >> 12) & 0xf), (((__SUNPRO_CC >> 8) & 0xf) * 10) + ((__SUNPRO_CC >> 4) & 0xf), (__SUNPRO_CC & 0xf) * 10)
360#elif defined(__SUNPRO_CC)
361 #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((__SUNPRO_CC >> 8) & 0xf, (__SUNPRO_CC >> 4) & 0xf, (__SUNPRO_CC) & 0xf)
364#if defined(JSON_HEDLEY_SUNPRO_VERSION_CHECK)
365 #undef JSON_HEDLEY_SUNPRO_VERSION_CHECK
367#if defined(JSON_HEDLEY_SUNPRO_VERSION)
368 #define JSON_HEDLEY_SUNPRO_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_SUNPRO_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
370 #define JSON_HEDLEY_SUNPRO_VERSION_CHECK(major,minor,patch) (0)
373#if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION)
374 #undef JSON_HEDLEY_EMSCRIPTEN_VERSION
376#if defined(__EMSCRIPTEN__)
377 #define JSON_HEDLEY_EMSCRIPTEN_VERSION JSON_HEDLEY_VERSION_ENCODE(__EMSCRIPTEN_major__, __EMSCRIPTEN_minor__, __EMSCRIPTEN_tiny__)
380#if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK)
381 #undef JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK
383#if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION)
384 #define JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_EMSCRIPTEN_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
386 #define JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK(major,minor,patch) (0)
389#if defined(JSON_HEDLEY_ARM_VERSION)
390 #undef JSON_HEDLEY_ARM_VERSION
392#if defined(__CC_ARM) && defined(__ARMCOMPILER_VERSION)
393 #define JSON_HEDLEY_ARM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ARMCOMPILER_VERSION / 1000000, (__ARMCOMPILER_VERSION % 1000000) / 10000, (__ARMCOMPILER_VERSION % 10000) / 100)
394#elif defined(__CC_ARM) && defined(__ARMCC_VERSION)
395 #define JSON_HEDLEY_ARM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ARMCC_VERSION / 1000000, (__ARMCC_VERSION % 1000000) / 10000, (__ARMCC_VERSION % 10000) / 100)
398#if defined(JSON_HEDLEY_ARM_VERSION_CHECK)
399 #undef JSON_HEDLEY_ARM_VERSION_CHECK
401#if defined(JSON_HEDLEY_ARM_VERSION)
402 #define JSON_HEDLEY_ARM_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_ARM_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
404 #define JSON_HEDLEY_ARM_VERSION_CHECK(major,minor,patch) (0)
407#if defined(JSON_HEDLEY_IBM_VERSION)
408 #undef JSON_HEDLEY_IBM_VERSION
410#if defined(__ibmxl__)
411 #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ibmxl_version__, __ibmxl_release__, __ibmxl_modification__)
412#elif defined(__xlC__) && defined(__xlC_ver__)
413 #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, (__xlC_ver__ >> 8) & 0xff)
414#elif defined(__xlC__)
415 #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, 0)
418#if defined(JSON_HEDLEY_IBM_VERSION_CHECK)
419 #undef JSON_HEDLEY_IBM_VERSION_CHECK
421#if defined(JSON_HEDLEY_IBM_VERSION)
422 #define JSON_HEDLEY_IBM_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_IBM_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
424 #define JSON_HEDLEY_IBM_VERSION_CHECK(major,minor,patch) (0)
427#if defined(JSON_HEDLEY_TI_VERSION)
428 #undef JSON_HEDLEY_TI_VERSION
431 defined(__TI_COMPILER_VERSION__) && \
433 defined(__TMS470__) || defined(__TI_ARM__) || \
434 defined(__MSP430__) || \
435 defined(__TMS320C2000__) \
437#if (__TI_COMPILER_VERSION__ >= 16000000)
438 #define JSON_HEDLEY_TI_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
442#if defined(JSON_HEDLEY_TI_VERSION_CHECK)
443 #undef JSON_HEDLEY_TI_VERSION_CHECK
445#if defined(JSON_HEDLEY_TI_VERSION)
446 #define JSON_HEDLEY_TI_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
448 #define JSON_HEDLEY_TI_VERSION_CHECK(major,minor,patch) (0)
451#if defined(JSON_HEDLEY_TI_CL2000_VERSION)
452 #undef JSON_HEDLEY_TI_CL2000_VERSION
454#if defined(__TI_COMPILER_VERSION__) && defined(__TMS320C2000__)
455 #define JSON_HEDLEY_TI_CL2000_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
458#if defined(JSON_HEDLEY_TI_CL2000_VERSION_CHECK)
459 #undef JSON_HEDLEY_TI_CL2000_VERSION_CHECK
461#if defined(JSON_HEDLEY_TI_CL2000_VERSION)
462 #define JSON_HEDLEY_TI_CL2000_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL2000_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
464 #define JSON_HEDLEY_TI_CL2000_VERSION_CHECK(major,minor,patch) (0)
467#if defined(JSON_HEDLEY_TI_CL430_VERSION)
468 #undef JSON_HEDLEY_TI_CL430_VERSION
470#if defined(__TI_COMPILER_VERSION__) && defined(__MSP430__)
471 #define JSON_HEDLEY_TI_CL430_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
474#if defined(JSON_HEDLEY_TI_CL430_VERSION_CHECK)
475 #undef JSON_HEDLEY_TI_CL430_VERSION_CHECK
477#if defined(JSON_HEDLEY_TI_CL430_VERSION)
478 #define JSON_HEDLEY_TI_CL430_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL430_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
480 #define JSON_HEDLEY_TI_CL430_VERSION_CHECK(major,minor,patch) (0)
483#if defined(JSON_HEDLEY_TI_ARMCL_VERSION)
484 #undef JSON_HEDLEY_TI_ARMCL_VERSION
486#if defined(__TI_COMPILER_VERSION__) && (defined(__TMS470__) || defined(__TI_ARM__))
487 #define JSON_HEDLEY_TI_ARMCL_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
490#if defined(JSON_HEDLEY_TI_ARMCL_VERSION_CHECK)
491 #undef JSON_HEDLEY_TI_ARMCL_VERSION_CHECK
493#if defined(JSON_HEDLEY_TI_ARMCL_VERSION)
494 #define JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_ARMCL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
496 #define JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(major,minor,patch) (0)
499#if defined(JSON_HEDLEY_TI_CL6X_VERSION)
500 #undef JSON_HEDLEY_TI_CL6X_VERSION
502#if defined(__TI_COMPILER_VERSION__) && defined(__TMS320C6X__)
503 #define JSON_HEDLEY_TI_CL6X_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
506#if defined(JSON_HEDLEY_TI_CL6X_VERSION_CHECK)
507 #undef JSON_HEDLEY_TI_CL6X_VERSION_CHECK
509#if defined(JSON_HEDLEY_TI_CL6X_VERSION)
510 #define JSON_HEDLEY_TI_CL6X_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL6X_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
512 #define JSON_HEDLEY_TI_CL6X_VERSION_CHECK(major,minor,patch) (0)
515#if defined(JSON_HEDLEY_TI_CL7X_VERSION)
516 #undef JSON_HEDLEY_TI_CL7X_VERSION
518#if defined(__TI_COMPILER_VERSION__) && defined(__C7000__)
519 #define JSON_HEDLEY_TI_CL7X_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
522#if defined(JSON_HEDLEY_TI_CL7X_VERSION_CHECK)
523 #undef JSON_HEDLEY_TI_CL7X_VERSION_CHECK
525#if defined(JSON_HEDLEY_TI_CL7X_VERSION)
526 #define JSON_HEDLEY_TI_CL7X_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL7X_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
528 #define JSON_HEDLEY_TI_CL7X_VERSION_CHECK(major,minor,patch) (0)
531#if defined(JSON_HEDLEY_TI_CLPRU_VERSION)
532 #undef JSON_HEDLEY_TI_CLPRU_VERSION
534#if defined(__TI_COMPILER_VERSION__) && defined(__PRU__)
535 #define JSON_HEDLEY_TI_CLPRU_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
538#if defined(JSON_HEDLEY_TI_CLPRU_VERSION_CHECK)
539 #undef JSON_HEDLEY_TI_CLPRU_VERSION_CHECK
541#if defined(JSON_HEDLEY_TI_CLPRU_VERSION)
542 #define JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CLPRU_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
544 #define JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(major,minor,patch) (0)
547#if defined(JSON_HEDLEY_CRAY_VERSION)
548 #undef JSON_HEDLEY_CRAY_VERSION
551 #if defined(_RELEASE_PATCHLEVEL)
552 #define JSON_HEDLEY_CRAY_VERSION JSON_HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, _RELEASE_PATCHLEVEL)
554 #define JSON_HEDLEY_CRAY_VERSION JSON_HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, 0)
558#if defined(JSON_HEDLEY_CRAY_VERSION_CHECK)
559 #undef JSON_HEDLEY_CRAY_VERSION_CHECK
561#if defined(JSON_HEDLEY_CRAY_VERSION)
562 #define JSON_HEDLEY_CRAY_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_CRAY_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
564 #define JSON_HEDLEY_CRAY_VERSION_CHECK(major,minor,patch) (0)
567#if defined(JSON_HEDLEY_IAR_VERSION)
568 #undef JSON_HEDLEY_IAR_VERSION
570#if defined(__IAR_SYSTEMS_ICC__)
572 #define JSON_HEDLEY_IAR_VERSION JSON_HEDLEY_VERSION_ENCODE((__VER__ / 1000000), ((__VER__ / 1000) % 1000), (__VER__ % 1000))
574 #define JSON_HEDLEY_IAR_VERSION JSON_HEDLEY_VERSION_ENCODE(__VER__ / 100, __VER__ % 100, 0)
578#if defined(JSON_HEDLEY_IAR_VERSION_CHECK)
579 #undef JSON_HEDLEY_IAR_VERSION_CHECK
581#if defined(JSON_HEDLEY_IAR_VERSION)
582 #define JSON_HEDLEY_IAR_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_IAR_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
584 #define JSON_HEDLEY_IAR_VERSION_CHECK(major,minor,patch) (0)
587#if defined(JSON_HEDLEY_TINYC_VERSION)
588 #undef JSON_HEDLEY_TINYC_VERSION
590#if defined(__TINYC__)
591 #define JSON_HEDLEY_TINYC_VERSION JSON_HEDLEY_VERSION_ENCODE(__TINYC__ / 1000, (__TINYC__ / 100) % 10, __TINYC__ % 100)
594#if defined(JSON_HEDLEY_TINYC_VERSION_CHECK)
595 #undef JSON_HEDLEY_TINYC_VERSION_CHECK
597#if defined(JSON_HEDLEY_TINYC_VERSION)
598 #define JSON_HEDLEY_TINYC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TINYC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
600 #define JSON_HEDLEY_TINYC_VERSION_CHECK(major,minor,patch) (0)
603#if defined(JSON_HEDLEY_DMC_VERSION)
604 #undef JSON_HEDLEY_DMC_VERSION
607 #define JSON_HEDLEY_DMC_VERSION JSON_HEDLEY_VERSION_ENCODE(__DMC__ >> 8, (__DMC__ >> 4) & 0xf, __DMC__ & 0xf)
610#if defined(JSON_HEDLEY_DMC_VERSION_CHECK)
611 #undef JSON_HEDLEY_DMC_VERSION_CHECK
613#if defined(JSON_HEDLEY_DMC_VERSION)
614 #define JSON_HEDLEY_DMC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_DMC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
616 #define JSON_HEDLEY_DMC_VERSION_CHECK(major,minor,patch) (0)
619#if defined(JSON_HEDLEY_COMPCERT_VERSION)
620 #undef JSON_HEDLEY_COMPCERT_VERSION
622#if defined(__COMPCERT_VERSION__)
623 #define JSON_HEDLEY_COMPCERT_VERSION JSON_HEDLEY_VERSION_ENCODE(__COMPCERT_VERSION__ / 10000, (__COMPCERT_VERSION__ / 100) % 100, __COMPCERT_VERSION__ % 100)
626#if defined(JSON_HEDLEY_COMPCERT_VERSION_CHECK)
627 #undef JSON_HEDLEY_COMPCERT_VERSION_CHECK
629#if defined(JSON_HEDLEY_COMPCERT_VERSION)
630 #define JSON_HEDLEY_COMPCERT_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_COMPCERT_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
632 #define JSON_HEDLEY_COMPCERT_VERSION_CHECK(major,minor,patch) (0)
635#if defined(JSON_HEDLEY_PELLES_VERSION)
636 #undef JSON_HEDLEY_PELLES_VERSION
639 #define JSON_HEDLEY_PELLES_VERSION JSON_HEDLEY_VERSION_ENCODE(__POCC__ / 100, __POCC__ % 100, 0)
642#if defined(JSON_HEDLEY_PELLES_VERSION_CHECK)
643 #undef JSON_HEDLEY_PELLES_VERSION_CHECK
645#if defined(JSON_HEDLEY_PELLES_VERSION)
646 #define JSON_HEDLEY_PELLES_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_PELLES_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
648 #define JSON_HEDLEY_PELLES_VERSION_CHECK(major,minor,patch) (0)
651#if defined(JSON_HEDLEY_MCST_LCC_VERSION)
652 #undef JSON_HEDLEY_MCST_LCC_VERSION
654#if defined(__LCC__) && defined(__LCC_MINOR__)
655 #define JSON_HEDLEY_MCST_LCC_VERSION JSON_HEDLEY_VERSION_ENCODE(__LCC__ / 100, __LCC__ % 100, __LCC_MINOR__)
658#if defined(JSON_HEDLEY_MCST_LCC_VERSION_CHECK)
659 #undef JSON_HEDLEY_MCST_LCC_VERSION_CHECK
661#if defined(JSON_HEDLEY_MCST_LCC_VERSION)
662 #define JSON_HEDLEY_MCST_LCC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_MCST_LCC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
664 #define JSON_HEDLEY_MCST_LCC_VERSION_CHECK(major,minor,patch) (0)
667#if defined(JSON_HEDLEY_GCC_VERSION)
668 #undef JSON_HEDLEY_GCC_VERSION
671 defined(JSON_HEDLEY_GNUC_VERSION) && \
672 !defined(__clang__) && \
673 !defined(JSON_HEDLEY_INTEL_VERSION) && \
674 !defined(JSON_HEDLEY_PGI_VERSION) && \
675 !defined(JSON_HEDLEY_ARM_VERSION) && \
676 !defined(JSON_HEDLEY_CRAY_VERSION) && \
677 !defined(JSON_HEDLEY_TI_VERSION) && \
678 !defined(JSON_HEDLEY_TI_ARMCL_VERSION) && \
679 !defined(JSON_HEDLEY_TI_CL430_VERSION) && \
680 !defined(JSON_HEDLEY_TI_CL2000_VERSION) && \
681 !defined(JSON_HEDLEY_TI_CL6X_VERSION) && \
682 !defined(JSON_HEDLEY_TI_CL7X_VERSION) && \
683 !defined(JSON_HEDLEY_TI_CLPRU_VERSION) && \
684 !defined(__COMPCERT__) && \
685 !defined(JSON_HEDLEY_MCST_LCC_VERSION)
686 #define JSON_HEDLEY_GCC_VERSION JSON_HEDLEY_GNUC_VERSION
689#if defined(JSON_HEDLEY_GCC_VERSION_CHECK)
690 #undef JSON_HEDLEY_GCC_VERSION_CHECK
692#if defined(JSON_HEDLEY_GCC_VERSION)
693 #define JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_GCC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
695 #define JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) (0)
698#if defined(JSON_HEDLEY_HAS_ATTRIBUTE)
699 #undef JSON_HEDLEY_HAS_ATTRIBUTE
702 defined(__has_attribute) && \
704 (!defined(JSON_HEDLEY_IAR_VERSION) || JSON_HEDLEY_IAR_VERSION_CHECK(8,5,9)) \
706# define JSON_HEDLEY_HAS_ATTRIBUTE(attribute) __has_attribute(attribute)
708# define JSON_HEDLEY_HAS_ATTRIBUTE(attribute) (0)
711#if defined(JSON_HEDLEY_GNUC_HAS_ATTRIBUTE)
712 #undef JSON_HEDLEY_GNUC_HAS_ATTRIBUTE
714#if defined(__has_attribute)
715 #define JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_HAS_ATTRIBUTE(attribute)
717 #define JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
720#if defined(JSON_HEDLEY_GCC_HAS_ATTRIBUTE)
721 #undef JSON_HEDLEY_GCC_HAS_ATTRIBUTE
723#if defined(__has_attribute)
724 #define JSON_HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_HAS_ATTRIBUTE(attribute)
726 #define JSON_HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
729#if defined(JSON_HEDLEY_HAS_CPP_ATTRIBUTE)
730 #undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE
733 defined(__has_cpp_attribute) && \
734 defined(__cplusplus) && \
735 (!defined(JSON_HEDLEY_SUNPRO_VERSION) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0))
736 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) __has_cpp_attribute(attribute)
738 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) (0)
741#if defined(JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS)
742 #undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS
744#if !defined(__cplusplus) || !defined(__has_cpp_attribute)
745 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) (0)
747 !defined(JSON_HEDLEY_PGI_VERSION) && \
748 !defined(JSON_HEDLEY_IAR_VERSION) && \
749 (!defined(JSON_HEDLEY_SUNPRO_VERSION) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0)) && \
750 (!defined(JSON_HEDLEY_MSVC_VERSION) || JSON_HEDLEY_MSVC_VERSION_CHECK(19,20,0))
751 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) JSON_HEDLEY_HAS_CPP_ATTRIBUTE(ns::attribute)
753 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) (0)
756#if defined(JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE)
757 #undef JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE
759#if defined(__has_cpp_attribute) && defined(__cplusplus)
760 #define JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) __has_cpp_attribute(attribute)
762 #define JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
765#if defined(JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE)
766 #undef JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE
768#if defined(__has_cpp_attribute) && defined(__cplusplus)
769 #define JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) __has_cpp_attribute(attribute)
771 #define JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
774#if defined(JSON_HEDLEY_HAS_BUILTIN)
775 #undef JSON_HEDLEY_HAS_BUILTIN
777#if defined(__has_builtin)
778 #define JSON_HEDLEY_HAS_BUILTIN(builtin) __has_builtin(builtin)
780 #define JSON_HEDLEY_HAS_BUILTIN(builtin) (0)
783#if defined(JSON_HEDLEY_GNUC_HAS_BUILTIN)
784 #undef JSON_HEDLEY_GNUC_HAS_BUILTIN
786#if defined(__has_builtin)
787 #define JSON_HEDLEY_GNUC_HAS_BUILTIN(builtin,major,minor,patch) __has_builtin(builtin)
789 #define JSON_HEDLEY_GNUC_HAS_BUILTIN(builtin,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
792#if defined(JSON_HEDLEY_GCC_HAS_BUILTIN)
793 #undef JSON_HEDLEY_GCC_HAS_BUILTIN
795#if defined(__has_builtin)
796 #define JSON_HEDLEY_GCC_HAS_BUILTIN(builtin,major,minor,patch) __has_builtin(builtin)
798 #define JSON_HEDLEY_GCC_HAS_BUILTIN(builtin,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
801#if defined(JSON_HEDLEY_HAS_FEATURE)
802 #undef JSON_HEDLEY_HAS_FEATURE
804#if defined(__has_feature)
805 #define JSON_HEDLEY_HAS_FEATURE(feature) __has_feature(feature)
807 #define JSON_HEDLEY_HAS_FEATURE(feature) (0)
810#if defined(JSON_HEDLEY_GNUC_HAS_FEATURE)
811 #undef JSON_HEDLEY_GNUC_HAS_FEATURE
813#if defined(__has_feature)
814 #define JSON_HEDLEY_GNUC_HAS_FEATURE(feature,major,minor,patch) __has_feature(feature)
816 #define JSON_HEDLEY_GNUC_HAS_FEATURE(feature,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
819#if defined(JSON_HEDLEY_GCC_HAS_FEATURE)
820 #undef JSON_HEDLEY_GCC_HAS_FEATURE
822#if defined(__has_feature)
823 #define JSON_HEDLEY_GCC_HAS_FEATURE(feature,major,minor,patch) __has_feature(feature)
825 #define JSON_HEDLEY_GCC_HAS_FEATURE(feature,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
828#if defined(JSON_HEDLEY_HAS_EXTENSION)
829 #undef JSON_HEDLEY_HAS_EXTENSION
831#if defined(__has_extension)
832 #define JSON_HEDLEY_HAS_EXTENSION(extension) __has_extension(extension)
834 #define JSON_HEDLEY_HAS_EXTENSION(extension) (0)
837#if defined(JSON_HEDLEY_GNUC_HAS_EXTENSION)
838 #undef JSON_HEDLEY_GNUC_HAS_EXTENSION
840#if defined(__has_extension)
841 #define JSON_HEDLEY_GNUC_HAS_EXTENSION(extension,major,minor,patch) __has_extension(extension)
843 #define JSON_HEDLEY_GNUC_HAS_EXTENSION(extension,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
846#if defined(JSON_HEDLEY_GCC_HAS_EXTENSION)
847 #undef JSON_HEDLEY_GCC_HAS_EXTENSION
849#if defined(__has_extension)
850 #define JSON_HEDLEY_GCC_HAS_EXTENSION(extension,major,minor,patch) __has_extension(extension)
852 #define JSON_HEDLEY_GCC_HAS_EXTENSION(extension,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
855#if defined(JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE)
856 #undef JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE
858#if defined(__has_declspec_attribute)
859 #define JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) __has_declspec_attribute(attribute)
861 #define JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) (0)
864#if defined(JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE)
865 #undef JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE
867#if defined(__has_declspec_attribute)
868 #define JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) __has_declspec_attribute(attribute)
870 #define JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
873#if defined(JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE)
874 #undef JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE
876#if defined(__has_declspec_attribute)
877 #define JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) __has_declspec_attribute(attribute)
879 #define JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
882#if defined(JSON_HEDLEY_HAS_WARNING)
883 #undef JSON_HEDLEY_HAS_WARNING
885#if defined(__has_warning)
886 #define JSON_HEDLEY_HAS_WARNING(warning) __has_warning(warning)
888 #define JSON_HEDLEY_HAS_WARNING(warning) (0)
891#if defined(JSON_HEDLEY_GNUC_HAS_WARNING)
892 #undef JSON_HEDLEY_GNUC_HAS_WARNING
894#if defined(__has_warning)
895 #define JSON_HEDLEY_GNUC_HAS_WARNING(warning,major,minor,patch) __has_warning(warning)
897 #define JSON_HEDLEY_GNUC_HAS_WARNING(warning,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
900#if defined(JSON_HEDLEY_GCC_HAS_WARNING)
901 #undef JSON_HEDLEY_GCC_HAS_WARNING
903#if defined(__has_warning)
904 #define JSON_HEDLEY_GCC_HAS_WARNING(warning,major,minor,patch) __has_warning(warning)
906 #define JSON_HEDLEY_GCC_HAS_WARNING(warning,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
910 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \
911 defined(__clang__) || \
912 JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) || \
913 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
914 JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \
915 JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) || \
916 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
917 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
918 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,7,0) || \
919 JSON_HEDLEY_TI_CL430_VERSION_CHECK(2,0,1) || \
920 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,1,0) || \
921 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,0,0) || \
922 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
923 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
924 JSON_HEDLEY_CRAY_VERSION_CHECK(5,0,0) || \
925 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,17) || \
926 JSON_HEDLEY_SUNPRO_VERSION_CHECK(8,0,0) || \
927 (JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) && defined(__C99_PRAGMA_OPERATOR))
928 #define JSON_HEDLEY_PRAGMA(value) _Pragma(#value)
929#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0)
930 #define JSON_HEDLEY_PRAGMA(value) __pragma(value)
932 #define JSON_HEDLEY_PRAGMA(value)
935#if defined(JSON_HEDLEY_DIAGNOSTIC_PUSH)
936 #undef JSON_HEDLEY_DIAGNOSTIC_PUSH
938#if defined(JSON_HEDLEY_DIAGNOSTIC_POP)
939 #undef JSON_HEDLEY_DIAGNOSTIC_POP
941#if defined(__clang__)
942 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("clang diagnostic push")
943 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("clang diagnostic pop")
944#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
945 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)")
946 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)")
947#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0)
948 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push")
949 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop")
951 JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) || \
952 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
953 #define JSON_HEDLEY_DIAGNOSTIC_PUSH __pragma(warning(push))
954 #define JSON_HEDLEY_DIAGNOSTIC_POP __pragma(warning(pop))
955#elif JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0)
956 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("push")
957 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("pop")
959 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
960 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
961 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,4,0) || \
962 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,1,0) || \
963 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
964 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0)
965 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("diag_push")
966 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("diag_pop")
967#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,90,0)
968 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)")
969 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)")
971 #define JSON_HEDLEY_DIAGNOSTIC_PUSH
972 #define JSON_HEDLEY_DIAGNOSTIC_POP
977#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_)
978 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_
980#if defined(__cplusplus)
981# if JSON_HEDLEY_HAS_WARNING("-Wc++98-compat")
982# if JSON_HEDLEY_HAS_WARNING("-Wc++17-extensions")
983# if JSON_HEDLEY_HAS_WARNING("-Wc++1z-extensions")
984# define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \
985 JSON_HEDLEY_DIAGNOSTIC_PUSH \
986 _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \
987 _Pragma("clang diagnostic ignored \"-Wc++17-extensions\"") \
988 _Pragma("clang diagnostic ignored \"-Wc++1z-extensions\"") \
990 JSON_HEDLEY_DIAGNOSTIC_POP
992# define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \
993 JSON_HEDLEY_DIAGNOSTIC_PUSH \
994 _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \
995 _Pragma("clang diagnostic ignored \"-Wc++17-extensions\"") \
997 JSON_HEDLEY_DIAGNOSTIC_POP
1000# define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \
1001 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1002 _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \
1004 JSON_HEDLEY_DIAGNOSTIC_POP
1008#if !defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_)
1009 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(x) x
1012#if defined(JSON_HEDLEY_CONST_CAST)
1013 #undef JSON_HEDLEY_CONST_CAST
1015#if defined(__cplusplus)
1016# define JSON_HEDLEY_CONST_CAST(T, expr) (const_cast<T>(expr))
1018 JSON_HEDLEY_HAS_WARNING("-Wcast-qual") || \
1019 JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0) || \
1020 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1021# define JSON_HEDLEY_CONST_CAST(T, expr) (__extension__ ({ \
1022 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1023 JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL \
1025 JSON_HEDLEY_DIAGNOSTIC_POP \
1028# define JSON_HEDLEY_CONST_CAST(T, expr) ((T) (expr))
1031#if defined(JSON_HEDLEY_REINTERPRET_CAST)
1032 #undef JSON_HEDLEY_REINTERPRET_CAST
1034#if defined(__cplusplus)
1035 #define JSON_HEDLEY_REINTERPRET_CAST(T, expr) (reinterpret_cast<T>(expr))
1037 #define JSON_HEDLEY_REINTERPRET_CAST(T, expr) ((T) (expr))
1040#if defined(JSON_HEDLEY_STATIC_CAST)
1041 #undef JSON_HEDLEY_STATIC_CAST
1043#if defined(__cplusplus)
1044 #define JSON_HEDLEY_STATIC_CAST(T, expr) (static_cast<T>(expr))
1046 #define JSON_HEDLEY_STATIC_CAST(T, expr) ((T) (expr))
1049#if defined(JSON_HEDLEY_CPP_CAST)
1050 #undef JSON_HEDLEY_CPP_CAST
1052#if defined(__cplusplus)
1053# if JSON_HEDLEY_HAS_WARNING("-Wold-style-cast")
1054# define JSON_HEDLEY_CPP_CAST(T, expr) \
1055 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1056 _Pragma("clang diagnostic ignored \"-Wold-style-cast\"") \
1058 JSON_HEDLEY_DIAGNOSTIC_POP
1059# elif JSON_HEDLEY_IAR_VERSION_CHECK(8,3,0)
1060# define JSON_HEDLEY_CPP_CAST(T, expr) \
1061 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1062 _Pragma("diag_suppress=Pe137") \
1063 JSON_HEDLEY_DIAGNOSTIC_POP
1065# define JSON_HEDLEY_CPP_CAST(T, expr) ((T) (expr))
1068# define JSON_HEDLEY_CPP_CAST(T, expr) (expr)
1071#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED)
1072 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED
1074#if JSON_HEDLEY_HAS_WARNING("-Wdeprecated-declarations")
1075 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"")
1076#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1077 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warning(disable:1478 1786)")
1078#elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1079 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED __pragma(warning(disable:1478 1786))
1080#elif JSON_HEDLEY_PGI_VERSION_CHECK(20,7,0)
1081 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1216,1444,1445")
1082#elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0)
1083 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1444")
1084#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0)
1085 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
1086#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0)
1087 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED __pragma(warning(disable:4996))
1088#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1089 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1444")
1091 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1092 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1093 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1094 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1095 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1096 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1097 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1098 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1099 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1100 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1101 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0)
1102 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1291,1718")
1103#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && !defined(__cplusplus)
1104 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,E_DEPRECATED_ATT,E_DEPRECATED_ATT_MESS)")
1105#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && defined(__cplusplus)
1106 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,symdeprecated,symdeprecated2)")
1107#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1108 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress=Pe1444,Pe1215")
1109#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,90,0)
1110 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warn(disable:2241)")
1112 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED
1115#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS)
1116 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS
1118#if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas")
1119 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("clang diagnostic ignored \"-Wunknown-pragmas\"")
1120#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1121 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("warning(disable:161)")
1122#elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1123 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS __pragma(warning(disable:161))
1124#elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0)
1125 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 1675")
1126#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0)
1127 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("GCC diagnostic ignored \"-Wunknown-pragmas\"")
1128#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0)
1129 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS __pragma(warning(disable:4068))
1131 JSON_HEDLEY_TI_VERSION_CHECK(16,9,0) || \
1132 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0) || \
1133 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1134 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,3,0)
1135 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163")
1136#elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0)
1137 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163")
1138#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1139 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress=Pe161")
1140#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1141 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 161")
1143 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS
1146#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES)
1147 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES
1149#if JSON_HEDLEY_HAS_WARNING("-Wunknown-attributes")
1150 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("clang diagnostic ignored \"-Wunknown-attributes\"")
1151#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0)
1152 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
1153#elif JSON_HEDLEY_INTEL_VERSION_CHECK(17,0,0)
1154 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("warning(disable:1292)")
1155#elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1156 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES __pragma(warning(disable:1292))
1157#elif JSON_HEDLEY_MSVC_VERSION_CHECK(19,0,0)
1158 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES __pragma(warning(disable:5030))
1159#elif JSON_HEDLEY_PGI_VERSION_CHECK(20,7,0)
1160 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097,1098")
1161#elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0)
1162 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097")
1163#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus)
1164 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("error_messages(off,attrskipunsup)")
1166 JSON_HEDLEY_TI_VERSION_CHECK(18,1,0) || \
1167 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,3,0) || \
1168 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0)
1169 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1173")
1170#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1171 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress=Pe1097")
1172#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1173 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097")
1175 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES
1178#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL)
1179 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL
1181#if JSON_HEDLEY_HAS_WARNING("-Wcast-qual")
1182 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("clang diagnostic ignored \"-Wcast-qual\"")
1183#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1184 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("warning(disable:2203 2331)")
1185#elif JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0)
1186 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("GCC diagnostic ignored \"-Wcast-qual\"")
1188 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL
1191#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION)
1192 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION
1194#if JSON_HEDLEY_HAS_WARNING("-Wunused-function")
1195 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("clang diagnostic ignored \"-Wunused-function\"")
1196#elif JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0)
1197 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("GCC diagnostic ignored \"-Wunused-function\"")
1198#elif JSON_HEDLEY_MSVC_VERSION_CHECK(1,0,0)
1199 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION __pragma(warning(disable:4505))
1200#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1201 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("diag_suppress 3142")
1203 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION
1206#if defined(JSON_HEDLEY_DEPRECATED)
1207 #undef JSON_HEDLEY_DEPRECATED
1209#if defined(JSON_HEDLEY_DEPRECATED_FOR)
1210 #undef JSON_HEDLEY_DEPRECATED_FOR
1213 JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \
1214 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1215 #define JSON_HEDLEY_DEPRECATED(since) __declspec(deprecated("Since " # since))
1216 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated("Since " #since "; use " #replacement))
1218 (JSON_HEDLEY_HAS_EXTENSION(attribute_deprecated_with_message) && !defined(JSON_HEDLEY_IAR_VERSION)) || \
1219 JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \
1220 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1221 JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) || \
1222 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) || \
1223 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1224 JSON_HEDLEY_TI_VERSION_CHECK(18,1,0) || \
1225 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(18,1,0) || \
1226 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,3,0) || \
1227 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1228 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,3,0) || \
1229 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1230 #define JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__("Since " #since)))
1231 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__("Since " #since "; use " #replacement)))
1232#elif defined(__cplusplus) && (__cplusplus >= 201402L)
1233 #define JSON_HEDLEY_DEPRECATED(since) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since)]])
1234 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since "; use " #replacement)]])
1236 JSON_HEDLEY_HAS_ATTRIBUTE(deprecated) || \
1237 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
1238 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1239 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1240 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1241 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1242 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1243 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1244 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1245 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1246 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1247 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1248 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1249 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1250 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \
1251 JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0)
1252 #define JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__))
1253 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__))
1255 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
1256 JSON_HEDLEY_PELLES_VERSION_CHECK(6,50,0) || \
1257 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1258 #define JSON_HEDLEY_DEPRECATED(since) __declspec(deprecated)
1259 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated)
1260#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1261 #define JSON_HEDLEY_DEPRECATED(since) _Pragma("deprecated")
1262 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) _Pragma("deprecated")
1264 #define JSON_HEDLEY_DEPRECATED(since)
1265 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement)
1268#if defined(JSON_HEDLEY_UNAVAILABLE)
1269 #undef JSON_HEDLEY_UNAVAILABLE
1272 JSON_HEDLEY_HAS_ATTRIBUTE(warning) || \
1273 JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0) || \
1274 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1275 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1276 #define JSON_HEDLEY_UNAVAILABLE(available_since) __attribute__((__warning__("Not available until " #available_since)))
1278 #define JSON_HEDLEY_UNAVAILABLE(available_since)
1281#if defined(JSON_HEDLEY_WARN_UNUSED_RESULT)
1282 #undef JSON_HEDLEY_WARN_UNUSED_RESULT
1284#if defined(JSON_HEDLEY_WARN_UNUSED_RESULT_MSG)
1285 #undef JSON_HEDLEY_WARN_UNUSED_RESULT_MSG
1288 JSON_HEDLEY_HAS_ATTRIBUTE(warn_unused_result) || \
1289 JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \
1290 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1291 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1292 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1293 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1294 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1295 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1296 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1297 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1298 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1299 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1300 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1301 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1302 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \
1303 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1304 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1305 #define JSON_HEDLEY_WARN_UNUSED_RESULT __attribute__((__warn_unused_result__))
1306 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) __attribute__((__warn_unused_result__))
1307#elif (JSON_HEDLEY_HAS_CPP_ATTRIBUTE(nodiscard) >= 201907L)
1308 #define JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]])
1309 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard(msg)]])
1310#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE(nodiscard)
1311 #define JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]])
1312 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]])
1313#elif defined(_Check_return_)
1314 #define JSON_HEDLEY_WARN_UNUSED_RESULT _Check_return_
1315 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) _Check_return_
1317 #define JSON_HEDLEY_WARN_UNUSED_RESULT
1318 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg)
1321#if defined(JSON_HEDLEY_SENTINEL)
1322 #undef JSON_HEDLEY_SENTINEL
1325 JSON_HEDLEY_HAS_ATTRIBUTE(sentinel) || \
1326 JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \
1327 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1328 JSON_HEDLEY_ARM_VERSION_CHECK(5,4,0) || \
1329 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1330 #define JSON_HEDLEY_SENTINEL(position) __attribute__((__sentinel__(position)))
1332 #define JSON_HEDLEY_SENTINEL(position)
1335#if defined(JSON_HEDLEY_NO_RETURN)
1336 #undef JSON_HEDLEY_NO_RETURN
1338#if JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1339 #define JSON_HEDLEY_NO_RETURN __noreturn
1341 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1342 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1343 #define JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__))
1344#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
1345 #define JSON_HEDLEY_NO_RETURN _Noreturn
1346#elif defined(__cplusplus) && (__cplusplus >= 201103L)
1347 #define JSON_HEDLEY_NO_RETURN JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[noreturn]])
1349 JSON_HEDLEY_HAS_ATTRIBUTE(noreturn) || \
1350 JSON_HEDLEY_GCC_VERSION_CHECK(3,2,0) || \
1351 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1352 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1353 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1354 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1355 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1356 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1357 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1358 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1359 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1360 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1361 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1362 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1363 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1364 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1365 JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0)
1366 #define JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__))
1367#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
1368 #define JSON_HEDLEY_NO_RETURN _Pragma("does_not_return")
1370 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
1371 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1372 #define JSON_HEDLEY_NO_RETURN __declspec(noreturn)
1373#elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,0,0) && defined(__cplusplus)
1374 #define JSON_HEDLEY_NO_RETURN _Pragma("FUNC_NEVER_RETURNS;")
1375#elif JSON_HEDLEY_COMPCERT_VERSION_CHECK(3,2,0)
1376 #define JSON_HEDLEY_NO_RETURN __attribute((noreturn))
1377#elif JSON_HEDLEY_PELLES_VERSION_CHECK(9,0,0)
1378 #define JSON_HEDLEY_NO_RETURN __declspec(noreturn)
1380 #define JSON_HEDLEY_NO_RETURN
1383#if defined(JSON_HEDLEY_NO_ESCAPE)
1384 #undef JSON_HEDLEY_NO_ESCAPE
1386#if JSON_HEDLEY_HAS_ATTRIBUTE(noescape)
1387 #define JSON_HEDLEY_NO_ESCAPE __attribute__((__noescape__))
1389 #define JSON_HEDLEY_NO_ESCAPE
1392#if defined(JSON_HEDLEY_UNREACHABLE)
1393 #undef JSON_HEDLEY_UNREACHABLE
1395#if defined(JSON_HEDLEY_UNREACHABLE_RETURN)
1396 #undef JSON_HEDLEY_UNREACHABLE_RETURN
1398#if defined(JSON_HEDLEY_ASSUME)
1399 #undef JSON_HEDLEY_ASSUME
1402 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
1403 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1404 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1405 #define JSON_HEDLEY_ASSUME(expr) __assume(expr)
1406#elif JSON_HEDLEY_HAS_BUILTIN(__builtin_assume)
1407 #define JSON_HEDLEY_ASSUME(expr) __builtin_assume(expr)
1409 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \
1410 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0)
1411 #if defined(__cplusplus)
1412 #define JSON_HEDLEY_ASSUME(expr) std::_nassert(expr)
1414 #define JSON_HEDLEY_ASSUME(expr) _nassert(expr)
1418 (JSON_HEDLEY_HAS_BUILTIN(__builtin_unreachable) && (!defined(JSON_HEDLEY_ARM_VERSION))) || \
1419 JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \
1420 JSON_HEDLEY_PGI_VERSION_CHECK(18,10,0) || \
1421 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1422 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,5) || \
1423 JSON_HEDLEY_CRAY_VERSION_CHECK(10,0,0) || \
1424 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1425 #define JSON_HEDLEY_UNREACHABLE() __builtin_unreachable()
1426#elif defined(JSON_HEDLEY_ASSUME)
1427 #define JSON_HEDLEY_UNREACHABLE() JSON_HEDLEY_ASSUME(0)
1429#if !defined(JSON_HEDLEY_ASSUME)
1430 #if defined(JSON_HEDLEY_UNREACHABLE)
1431 #define JSON_HEDLEY_ASSUME(expr) JSON_HEDLEY_STATIC_CAST(void, ((expr) ? 1 : (JSON_HEDLEY_UNREACHABLE(), 1)))
1433 #define JSON_HEDLEY_ASSUME(expr) JSON_HEDLEY_STATIC_CAST(void, expr)
1436#if defined(JSON_HEDLEY_UNREACHABLE)
1438 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \
1439 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0)
1440 #define JSON_HEDLEY_UNREACHABLE_RETURN(value) return (JSON_HEDLEY_STATIC_CAST(void, JSON_HEDLEY_ASSUME(0)), (value))
1442 #define JSON_HEDLEY_UNREACHABLE_RETURN(value) JSON_HEDLEY_UNREACHABLE()
1445 #define JSON_HEDLEY_UNREACHABLE_RETURN(value) return (value)
1447#if !defined(JSON_HEDLEY_UNREACHABLE)
1448 #define JSON_HEDLEY_UNREACHABLE() JSON_HEDLEY_ASSUME(0)
1452#if JSON_HEDLEY_HAS_WARNING("-Wpedantic")
1453 #pragma clang diagnostic ignored "-Wpedantic"
1455#if JSON_HEDLEY_HAS_WARNING("-Wc++98-compat-pedantic") && defined(__cplusplus)
1456 #pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
1458#if JSON_HEDLEY_GCC_HAS_WARNING("-Wvariadic-macros",4,0,0)
1459 #if defined(__clang__)
1460 #pragma clang diagnostic ignored "-Wvariadic-macros"
1461 #elif defined(JSON_HEDLEY_GCC_VERSION)
1462 #pragma GCC diagnostic ignored "-Wvariadic-macros"
1465#if defined(JSON_HEDLEY_NON_NULL)
1466 #undef JSON_HEDLEY_NON_NULL
1469 JSON_HEDLEY_HAS_ATTRIBUTE(nonnull) || \
1470 JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \
1471 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1472 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0)
1473 #define JSON_HEDLEY_NON_NULL(...) __attribute__((__nonnull__(__VA_ARGS__)))
1475 #define JSON_HEDLEY_NON_NULL(...)
1479#if defined(JSON_HEDLEY_PRINTF_FORMAT)
1480 #undef JSON_HEDLEY_PRINTF_FORMAT
1482#if defined(__MINGW32__) && JSON_HEDLEY_GCC_HAS_ATTRIBUTE(format,4,4,0) && !defined(__USE_MINGW_ANSI_STDIO)
1483 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(ms_printf, string_idx, first_to_check)))
1484#elif defined(__MINGW32__) && JSON_HEDLEY_GCC_HAS_ATTRIBUTE(format,4,4,0) && defined(__USE_MINGW_ANSI_STDIO)
1485 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(gnu_printf, string_idx, first_to_check)))
1487 JSON_HEDLEY_HAS_ATTRIBUTE(format) || \
1488 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
1489 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1490 JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) || \
1491 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1492 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1493 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1494 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1495 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1496 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1497 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1498 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1499 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1500 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1501 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1502 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1503 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1504 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(__printf__, string_idx, first_to_check)))
1505#elif JSON_HEDLEY_PELLES_VERSION_CHECK(6,0,0)
1506 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __declspec(vaformat(printf,string_idx,first_to_check))
1508 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check)
1511#if defined(JSON_HEDLEY_CONSTEXPR)
1512 #undef JSON_HEDLEY_CONSTEXPR
1514#if defined(__cplusplus)
1515 #if __cplusplus >= 201103L
1516 #define JSON_HEDLEY_CONSTEXPR JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(constexpr)
1519#if !defined(JSON_HEDLEY_CONSTEXPR)
1520 #define JSON_HEDLEY_CONSTEXPR
1523#if defined(JSON_HEDLEY_PREDICT)
1524 #undef JSON_HEDLEY_PREDICT
1526#if defined(JSON_HEDLEY_LIKELY)
1527 #undef JSON_HEDLEY_LIKELY
1529#if defined(JSON_HEDLEY_UNLIKELY)
1530 #undef JSON_HEDLEY_UNLIKELY
1532#if defined(JSON_HEDLEY_UNPREDICTABLE)
1533 #undef JSON_HEDLEY_UNPREDICTABLE
1535#if JSON_HEDLEY_HAS_BUILTIN(__builtin_unpredictable)
1536 #define JSON_HEDLEY_UNPREDICTABLE(expr) __builtin_unpredictable((expr))
1539 (JSON_HEDLEY_HAS_BUILTIN(__builtin_expect_with_probability) && !defined(JSON_HEDLEY_PGI_VERSION)) || \
1540 JSON_HEDLEY_GCC_VERSION_CHECK(9,0,0) || \
1541 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1542# define JSON_HEDLEY_PREDICT(expr, value, probability) __builtin_expect_with_probability( (expr), (value), (probability))
1543# define JSON_HEDLEY_PREDICT_TRUE(expr, probability) __builtin_expect_with_probability(!!(expr), 1 , (probability))
1544# define JSON_HEDLEY_PREDICT_FALSE(expr, probability) __builtin_expect_with_probability(!!(expr), 0 , (probability))
1545# define JSON_HEDLEY_LIKELY(expr) __builtin_expect (!!(expr), 1 )
1546# define JSON_HEDLEY_UNLIKELY(expr) __builtin_expect (!!(expr), 0 )
1548 (JSON_HEDLEY_HAS_BUILTIN(__builtin_expect) && !defined(JSON_HEDLEY_INTEL_CL_VERSION)) || \
1549 JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) || \
1550 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1551 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \
1552 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1553 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1554 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1555 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,7,0) || \
1556 JSON_HEDLEY_TI_CL430_VERSION_CHECK(3,1,0) || \
1557 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,1,0) || \
1558 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \
1559 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1560 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1561 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,27) || \
1562 JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \
1563 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1564# define JSON_HEDLEY_PREDICT(expr, expected, probability) \
1565 (((probability) >= 0.9) ? __builtin_expect((expr), (expected)) : (JSON_HEDLEY_STATIC_CAST(void, expected), (expr)))
1566# define JSON_HEDLEY_PREDICT_TRUE(expr, probability) \
1568 double hedley_probability_ = (probability); \
1569 ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 1) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 0) : !!(expr))); \
1571# define JSON_HEDLEY_PREDICT_FALSE(expr, probability) \
1573 double hedley_probability_ = (probability); \
1574 ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 0) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 1) : !!(expr))); \
1576# define JSON_HEDLEY_LIKELY(expr) __builtin_expect(!!(expr), 1)
1577# define JSON_HEDLEY_UNLIKELY(expr) __builtin_expect(!!(expr), 0)
1579# define JSON_HEDLEY_PREDICT(expr, expected, probability) (JSON_HEDLEY_STATIC_CAST(void, expected), (expr))
1580# define JSON_HEDLEY_PREDICT_TRUE(expr, probability) (!!(expr))
1581# define JSON_HEDLEY_PREDICT_FALSE(expr, probability) (!!(expr))
1582# define JSON_HEDLEY_LIKELY(expr) (!!(expr))
1583# define JSON_HEDLEY_UNLIKELY(expr) (!!(expr))
1585#if !defined(JSON_HEDLEY_UNPREDICTABLE)
1586 #define JSON_HEDLEY_UNPREDICTABLE(expr) JSON_HEDLEY_PREDICT(expr, 1, 0.5)
1589#if defined(JSON_HEDLEY_MALLOC)
1590 #undef JSON_HEDLEY_MALLOC
1593 JSON_HEDLEY_HAS_ATTRIBUTE(malloc) || \
1594 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
1595 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1596 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1597 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1598 JSON_HEDLEY_IBM_VERSION_CHECK(12,1,0) || \
1599 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1600 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1601 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1602 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1603 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1604 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1605 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1606 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1607 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1608 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1609 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1610 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1611 #define JSON_HEDLEY_MALLOC __attribute__((__malloc__))
1612#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
1613 #define JSON_HEDLEY_MALLOC _Pragma("returns_new_memory")
1615 JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \
1616 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1617 #define JSON_HEDLEY_MALLOC __declspec(restrict)
1619 #define JSON_HEDLEY_MALLOC
1622#if defined(JSON_HEDLEY_PURE)
1623 #undef JSON_HEDLEY_PURE
1626 JSON_HEDLEY_HAS_ATTRIBUTE(pure) || \
1627 JSON_HEDLEY_GCC_VERSION_CHECK(2,96,0) || \
1628 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1629 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1630 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1631 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1632 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1633 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1634 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1635 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1636 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1637 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1638 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1639 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1640 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1641 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1642 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1643 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1644 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1645# define JSON_HEDLEY_PURE __attribute__((__pure__))
1646#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
1647# define JSON_HEDLEY_PURE _Pragma("does_not_write_global_data")
1648#elif defined(__cplusplus) && \
1650 JSON_HEDLEY_TI_CL430_VERSION_CHECK(2,0,1) || \
1651 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0) || \
1652 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) \
1654# define JSON_HEDLEY_PURE _Pragma("FUNC_IS_PURE;")
1656# define JSON_HEDLEY_PURE
1659#if defined(JSON_HEDLEY_CONST)
1660 #undef JSON_HEDLEY_CONST
1663 JSON_HEDLEY_HAS_ATTRIBUTE(const) || \
1664 JSON_HEDLEY_GCC_VERSION_CHECK(2,5,0) || \
1665 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1666 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1667 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1668 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1669 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1670 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1671 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1672 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1673 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1674 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1675 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1676 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1677 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1678 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1679 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1680 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1681 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1682 #define JSON_HEDLEY_CONST __attribute__((__const__))
1684 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
1685 #define JSON_HEDLEY_CONST _Pragma("no_side_effect")
1687 #define JSON_HEDLEY_CONST JSON_HEDLEY_PURE
1690#if defined(JSON_HEDLEY_RESTRICT)
1691 #undef JSON_HEDLEY_RESTRICT
1693#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && !defined(__cplusplus)
1694 #define JSON_HEDLEY_RESTRICT restrict
1696 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
1697 JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \
1698 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1699 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \
1700 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1701 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1702 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1703 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1704 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,4) || \
1705 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,1,0) || \
1706 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1707 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus)) || \
1708 JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \
1709 defined(__clang__) || \
1710 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1711 #define JSON_HEDLEY_RESTRICT __restrict
1712#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,3,0) && !defined(__cplusplus)
1713 #define JSON_HEDLEY_RESTRICT _Restrict
1715 #define JSON_HEDLEY_RESTRICT
1718#if defined(JSON_HEDLEY_INLINE)
1719 #undef JSON_HEDLEY_INLINE
1722 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \
1723 (defined(__cplusplus) && (__cplusplus >= 199711L))
1724 #define JSON_HEDLEY_INLINE inline
1726 defined(JSON_HEDLEY_GCC_VERSION) || \
1727 JSON_HEDLEY_ARM_VERSION_CHECK(6,2,0)
1728 #define JSON_HEDLEY_INLINE __inline__
1730 JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0) || \
1731 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \
1732 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1733 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,1,0) || \
1734 JSON_HEDLEY_TI_CL430_VERSION_CHECK(3,1,0) || \
1735 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \
1736 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0) || \
1737 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1738 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1739 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1740 #define JSON_HEDLEY_INLINE __inline
1742 #define JSON_HEDLEY_INLINE
1745#if defined(JSON_HEDLEY_ALWAYS_INLINE)
1746 #undef JSON_HEDLEY_ALWAYS_INLINE
1749 JSON_HEDLEY_HAS_ATTRIBUTE(always_inline) || \
1750 JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \
1751 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1752 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1753 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1754 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1755 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1756 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1757 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1758 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1759 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1760 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1761 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1762 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1763 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1764 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1765 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1766 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \
1767 JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0)
1768# define JSON_HEDLEY_ALWAYS_INLINE __attribute__((__always_inline__)) JSON_HEDLEY_INLINE
1770 JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0) || \
1771 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1772# define JSON_HEDLEY_ALWAYS_INLINE __forceinline
1773#elif defined(__cplusplus) && \
1775 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1776 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1777 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1778 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \
1779 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1780 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) \
1782# define JSON_HEDLEY_ALWAYS_INLINE _Pragma("FUNC_ALWAYS_INLINE;")
1783#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1784# define JSON_HEDLEY_ALWAYS_INLINE _Pragma("inline=forced")
1786# define JSON_HEDLEY_ALWAYS_INLINE JSON_HEDLEY_INLINE
1789#if defined(JSON_HEDLEY_NEVER_INLINE)
1790 #undef JSON_HEDLEY_NEVER_INLINE
1793 JSON_HEDLEY_HAS_ATTRIBUTE(noinline) || \
1794 JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \
1795 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1796 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1797 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1798 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1799 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1800 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1801 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1802 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1803 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1804 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1805 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1806 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1807 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1808 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1809 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1810 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \
1811 JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0)
1812 #define JSON_HEDLEY_NEVER_INLINE __attribute__((__noinline__))
1814 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
1815 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1816 #define JSON_HEDLEY_NEVER_INLINE __declspec(noinline)
1817#elif JSON_HEDLEY_PGI_VERSION_CHECK(10,2,0)
1818 #define JSON_HEDLEY_NEVER_INLINE _Pragma("noinline")
1819#elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,0,0) && defined(__cplusplus)
1820 #define JSON_HEDLEY_NEVER_INLINE _Pragma("FUNC_CANNOT_INLINE;")
1821#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1822 #define JSON_HEDLEY_NEVER_INLINE _Pragma("inline=never")
1823#elif JSON_HEDLEY_COMPCERT_VERSION_CHECK(3,2,0)
1824 #define JSON_HEDLEY_NEVER_INLINE __attribute((noinline))
1825#elif JSON_HEDLEY_PELLES_VERSION_CHECK(9,0,0)
1826 #define JSON_HEDLEY_NEVER_INLINE __declspec(noinline)
1828 #define JSON_HEDLEY_NEVER_INLINE
1831#if defined(JSON_HEDLEY_PRIVATE)
1832 #undef JSON_HEDLEY_PRIVATE
1834#if defined(JSON_HEDLEY_PUBLIC)
1835 #undef JSON_HEDLEY_PUBLIC
1837#if defined(JSON_HEDLEY_IMPORT)
1838 #undef JSON_HEDLEY_IMPORT
1840#if defined(_WIN32) || defined(__CYGWIN__)
1841# define JSON_HEDLEY_PRIVATE
1842# define JSON_HEDLEY_PUBLIC __declspec(dllexport)
1843# define JSON_HEDLEY_IMPORT __declspec(dllimport)
1846 JSON_HEDLEY_HAS_ATTRIBUTE(visibility) || \
1847 JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \
1848 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1849 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1850 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1851 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \
1853 defined(__TI_EABI__) && \
1855 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1856 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) \
1859 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1860# define JSON_HEDLEY_PRIVATE __attribute__((__visibility__("hidden")))
1861# define JSON_HEDLEY_PUBLIC __attribute__((__visibility__("default")))
1863# define JSON_HEDLEY_PRIVATE
1864# define JSON_HEDLEY_PUBLIC
1866# define JSON_HEDLEY_IMPORT extern
1869#if defined(JSON_HEDLEY_NO_THROW)
1870 #undef JSON_HEDLEY_NO_THROW
1873 JSON_HEDLEY_HAS_ATTRIBUTE(nothrow) || \
1874 JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \
1875 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1876 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1877 #define JSON_HEDLEY_NO_THROW __attribute__((__nothrow__))
1879 JSON_HEDLEY_MSVC_VERSION_CHECK(13,1,0) || \
1880 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \
1881 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0)
1882 #define JSON_HEDLEY_NO_THROW __declspec(nothrow)
1884 #define JSON_HEDLEY_NO_THROW
1887#if defined(JSON_HEDLEY_FALL_THROUGH)
1888 #undef JSON_HEDLEY_FALL_THROUGH
1891 JSON_HEDLEY_HAS_ATTRIBUTE(fallthrough) || \
1892 JSON_HEDLEY_GCC_VERSION_CHECK(7,0,0) || \
1893 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1894 #define JSON_HEDLEY_FALL_THROUGH __attribute__((__fallthrough__))
1895#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(clang,fallthrough)
1896 #define JSON_HEDLEY_FALL_THROUGH JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[clang::fallthrough]])
1897#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE(fallthrough)
1898 #define JSON_HEDLEY_FALL_THROUGH JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[fallthrough]])
1899#elif defined(__fallthrough)
1900 #define JSON_HEDLEY_FALL_THROUGH __fallthrough
1902 #define JSON_HEDLEY_FALL_THROUGH
1905#if defined(JSON_HEDLEY_RETURNS_NON_NULL)
1906 #undef JSON_HEDLEY_RETURNS_NON_NULL
1909 JSON_HEDLEY_HAS_ATTRIBUTE(returns_nonnull) || \
1910 JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) || \
1911 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1912 #define JSON_HEDLEY_RETURNS_NON_NULL __attribute__((__returns_nonnull__))
1913#elif defined(_Ret_notnull_)
1914 #define JSON_HEDLEY_RETURNS_NON_NULL _Ret_notnull_
1916 #define JSON_HEDLEY_RETURNS_NON_NULL
1919#if defined(JSON_HEDLEY_ARRAY_PARAM)
1920 #undef JSON_HEDLEY_ARRAY_PARAM
1923 defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && \
1924 !defined(__STDC_NO_VLA__) && \
1925 !defined(__cplusplus) && \
1926 !defined(JSON_HEDLEY_PGI_VERSION) && \
1927 !defined(JSON_HEDLEY_TINYC_VERSION)
1928 #define JSON_HEDLEY_ARRAY_PARAM(name) (name)
1930 #define JSON_HEDLEY_ARRAY_PARAM(name)
1933#if defined(JSON_HEDLEY_IS_CONSTANT)
1934 #undef JSON_HEDLEY_IS_CONSTANT
1936#if defined(JSON_HEDLEY_REQUIRE_CONSTEXPR)
1937 #undef JSON_HEDLEY_REQUIRE_CONSTEXPR
1941#if defined(JSON_HEDLEY_IS_CONSTEXPR_)
1942 #undef JSON_HEDLEY_IS_CONSTEXPR_
1945 JSON_HEDLEY_HAS_BUILTIN(__builtin_constant_p) || \
1946 JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \
1947 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1948 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,19) || \
1949 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1950 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \
1951 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \
1952 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) && !defined(__cplusplus)) || \
1953 JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \
1954 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1955 #define JSON_HEDLEY_IS_CONSTANT(expr) __builtin_constant_p(expr)
1957#if !defined(__cplusplus)
1959 JSON_HEDLEY_HAS_BUILTIN(__builtin_types_compatible_p) || \
1960 JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \
1961 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1962 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \
1963 JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \
1964 JSON_HEDLEY_ARM_VERSION_CHECK(5,4,0) || \
1965 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,24)
1966#if defined(__INTPTR_TYPE__)
1967 #define JSON_HEDLEY_IS_CONSTEXPR_(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((__INTPTR_TYPE__) ((expr) * 0)) : (int*) 0)), int*)
1970 #define JSON_HEDLEY_IS_CONSTEXPR_(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((intptr_t) ((expr) * 0)) : (int*) 0)), int*)
1974 defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) && \
1975 !defined(JSON_HEDLEY_SUNPRO_VERSION) && \
1976 !defined(JSON_HEDLEY_PGI_VERSION) && \
1977 !defined(JSON_HEDLEY_IAR_VERSION)) || \
1978 (JSON_HEDLEY_HAS_EXTENSION(c_generic_selections) && !defined(JSON_HEDLEY_IAR_VERSION)) || \
1979 JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) || \
1980 JSON_HEDLEY_INTEL_VERSION_CHECK(17,0,0) || \
1981 JSON_HEDLEY_IBM_VERSION_CHECK(12,1,0) || \
1982 JSON_HEDLEY_ARM_VERSION_CHECK(5,3,0)
1983#if defined(__INTPTR_TYPE__)
1984 #define JSON_HEDLEY_IS_CONSTEXPR_(expr) _Generic((1 ? (void*) ((__INTPTR_TYPE__) ((expr) * 0)) : (int*) 0), int*: 1, void*: 0)
1987 #define JSON_HEDLEY_IS_CONSTEXPR_(expr) _Generic((1 ? (void*) ((intptr_t) * 0) : (int*) 0), int*: 1, void*: 0)
1990 defined(JSON_HEDLEY_GCC_VERSION) || \
1991 defined(JSON_HEDLEY_INTEL_VERSION) || \
1992 defined(JSON_HEDLEY_TINYC_VERSION) || \
1993 defined(JSON_HEDLEY_TI_ARMCL_VERSION) || \
1994 JSON_HEDLEY_TI_CL430_VERSION_CHECK(18,12,0) || \
1995 defined(JSON_HEDLEY_TI_CL2000_VERSION) || \
1996 defined(JSON_HEDLEY_TI_CL6X_VERSION) || \
1997 defined(JSON_HEDLEY_TI_CL7X_VERSION) || \
1998 defined(JSON_HEDLEY_TI_CLPRU_VERSION) || \
2000# define JSON_HEDLEY_IS_CONSTEXPR_(expr) ( \
2004 ((void*) ((expr) * 0L) ) : \
2005((struct { char v[sizeof(void) * 2]; } *) 1) \
2011#if defined(JSON_HEDLEY_IS_CONSTEXPR_)
2012 #if !defined(JSON_HEDLEY_IS_CONSTANT)
2013 #define JSON_HEDLEY_IS_CONSTANT(expr) JSON_HEDLEY_IS_CONSTEXPR_(expr)
2015 #define JSON_HEDLEY_REQUIRE_CONSTEXPR(expr) (JSON_HEDLEY_IS_CONSTEXPR_(expr) ? (expr) : (-1))
2017 #if !defined(JSON_HEDLEY_IS_CONSTANT)
2018 #define JSON_HEDLEY_IS_CONSTANT(expr) (0)
2020 #define JSON_HEDLEY_REQUIRE_CONSTEXPR(expr) (expr)
2023#if defined(JSON_HEDLEY_BEGIN_C_DECLS)
2024 #undef JSON_HEDLEY_BEGIN_C_DECLS
2026#if defined(JSON_HEDLEY_END_C_DECLS)
2027 #undef JSON_HEDLEY_END_C_DECLS
2029#if defined(JSON_HEDLEY_C_DECL)
2030 #undef JSON_HEDLEY_C_DECL
2032#if defined(__cplusplus)
2033 #define JSON_HEDLEY_BEGIN_C_DECLS extern "C" {
2034 #define JSON_HEDLEY_END_C_DECLS }
2035 #define JSON_HEDLEY_C_DECL extern "C"
2037 #define JSON_HEDLEY_BEGIN_C_DECLS
2038 #define JSON_HEDLEY_END_C_DECLS
2039 #define JSON_HEDLEY_C_DECL
2042#if defined(JSON_HEDLEY_STATIC_ASSERT)
2043 #undef JSON_HEDLEY_STATIC_ASSERT
2046 !defined(__cplusplus) && ( \
2047 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)) || \
2048 (JSON_HEDLEY_HAS_FEATURE(c_static_assert) && !defined(JSON_HEDLEY_INTEL_CL_VERSION)) || \
2049 JSON_HEDLEY_GCC_VERSION_CHECK(6,0,0) || \
2050 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
2051 defined(_Static_assert) \
2053# define JSON_HEDLEY_STATIC_ASSERT(expr, message) _Static_assert(expr, message)
2055 (defined(__cplusplus) && (__cplusplus >= 201103L)) || \
2056 JSON_HEDLEY_MSVC_VERSION_CHECK(16,0,0) || \
2057 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
2058# define JSON_HEDLEY_STATIC_ASSERT(expr, message) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(static_assert(expr, message))
2060# define JSON_HEDLEY_STATIC_ASSERT(expr, message)
2063#if defined(JSON_HEDLEY_NULL)
2064 #undef JSON_HEDLEY_NULL
2066#if defined(__cplusplus)
2067 #if __cplusplus >= 201103L
2068 #define JSON_HEDLEY_NULL JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(nullptr)
2070 #define JSON_HEDLEY_NULL NULL
2072 #define JSON_HEDLEY_NULL JSON_HEDLEY_STATIC_CAST(void*, 0)
2075 #define JSON_HEDLEY_NULL NULL
2077 #define JSON_HEDLEY_NULL ((void*) 0)
2080#if defined(JSON_HEDLEY_MESSAGE)
2081 #undef JSON_HEDLEY_MESSAGE
2083#if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas")
2084# define JSON_HEDLEY_MESSAGE(msg) \
2085 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2086 JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \
2087 JSON_HEDLEY_PRAGMA(message msg) \
2088 JSON_HEDLEY_DIAGNOSTIC_POP
2090 JSON_HEDLEY_GCC_VERSION_CHECK(4,4,0) || \
2091 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
2092# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message msg)
2093#elif JSON_HEDLEY_CRAY_VERSION_CHECK(5,0,0)
2094# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(_CRI message msg)
2095#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
2096# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message(msg))
2097#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,0,0)
2098# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message(msg))
2100# define JSON_HEDLEY_MESSAGE(msg)
2103#if defined(JSON_HEDLEY_WARNING)
2104 #undef JSON_HEDLEY_WARNING
2106#if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas")
2107# define JSON_HEDLEY_WARNING(msg) \
2108 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2109 JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \
2110 JSON_HEDLEY_PRAGMA(clang warning msg) \
2111 JSON_HEDLEY_DIAGNOSTIC_POP
2113 JSON_HEDLEY_GCC_VERSION_CHECK(4,8,0) || \
2114 JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) || \
2115 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
2116# define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_PRAGMA(GCC warning msg)
2118 JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) || \
2119 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
2120# define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_PRAGMA(message(msg))
2122# define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_MESSAGE(msg)
2125#if defined(JSON_HEDLEY_REQUIRE)
2126 #undef JSON_HEDLEY_REQUIRE
2128#if defined(JSON_HEDLEY_REQUIRE_MSG)
2129 #undef JSON_HEDLEY_REQUIRE_MSG
2131#if JSON_HEDLEY_HAS_ATTRIBUTE(diagnose_if)
2132# if JSON_HEDLEY_HAS_WARNING("-Wgcc-compat")
2133# define JSON_HEDLEY_REQUIRE(expr) \
2134 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2135 _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") \
2136 __attribute__((diagnose_if(!(expr), #expr, "error"))) \
2137 JSON_HEDLEY_DIAGNOSTIC_POP
2138# define JSON_HEDLEY_REQUIRE_MSG(expr,msg) \
2139 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2140 _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") \
2141 __attribute__((diagnose_if(!(expr), msg, "error"))) \
2142 JSON_HEDLEY_DIAGNOSTIC_POP
2144# define JSON_HEDLEY_REQUIRE(expr) __attribute__((diagnose_if(!(expr), #expr, "error")))
2145# define JSON_HEDLEY_REQUIRE_MSG(expr,msg) __attribute__((diagnose_if(!(expr), msg, "error")))
2148# define JSON_HEDLEY_REQUIRE(expr)
2149# define JSON_HEDLEY_REQUIRE_MSG(expr,msg)
2152#if defined(JSON_HEDLEY_FLAGS)
2153 #undef JSON_HEDLEY_FLAGS
2155#if JSON_HEDLEY_HAS_ATTRIBUTE(flag_enum) && (!defined(__cplusplus) || JSON_HEDLEY_HAS_WARNING("-Wbitfield-enum-conversion"))
2156 #define JSON_HEDLEY_FLAGS __attribute__((__flag_enum__))
2158 #define JSON_HEDLEY_FLAGS
2161#if defined(JSON_HEDLEY_FLAGS_CAST)
2162 #undef JSON_HEDLEY_FLAGS_CAST
2164#if JSON_HEDLEY_INTEL_VERSION_CHECK(19,0,0)
2165# define JSON_HEDLEY_FLAGS_CAST(T, expr) (__extension__ ({ \
2166 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2167 _Pragma("warning(disable:188)") \
2169 JSON_HEDLEY_DIAGNOSTIC_POP \
2172# define JSON_HEDLEY_FLAGS_CAST(T, expr) JSON_HEDLEY_STATIC_CAST(T, expr)
2175#if defined(JSON_HEDLEY_EMPTY_BASES)
2176 #undef JSON_HEDLEY_EMPTY_BASES
2179 (JSON_HEDLEY_MSVC_VERSION_CHECK(19,0,23918) && !JSON_HEDLEY_MSVC_VERSION_CHECK(20,0,0)) || \
2180 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
2181 #define JSON_HEDLEY_EMPTY_BASES __declspec(empty_bases)
2183 #define JSON_HEDLEY_EMPTY_BASES
2188#if defined(JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK)
2189 #undef JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK
2191#if defined(__clang__)
2192 #define JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major,minor,patch) (0)
2194 #define JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
2197#if defined(JSON_HEDLEY_CLANG_HAS_ATTRIBUTE)
2198 #undef JSON_HEDLEY_CLANG_HAS_ATTRIBUTE
2200#define JSON_HEDLEY_CLANG_HAS_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_ATTRIBUTE(attribute)
2202#if defined(JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE)
2203 #undef JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE
2205#define JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute)
2207#if defined(JSON_HEDLEY_CLANG_HAS_BUILTIN)
2208 #undef JSON_HEDLEY_CLANG_HAS_BUILTIN
2210#define JSON_HEDLEY_CLANG_HAS_BUILTIN(builtin) JSON_HEDLEY_HAS_BUILTIN(builtin)
2212#if defined(JSON_HEDLEY_CLANG_HAS_FEATURE)
2213 #undef JSON_HEDLEY_CLANG_HAS_FEATURE
2215#define JSON_HEDLEY_CLANG_HAS_FEATURE(feature) JSON_HEDLEY_HAS_FEATURE(feature)
2217#if defined(JSON_HEDLEY_CLANG_HAS_EXTENSION)
2218 #undef JSON_HEDLEY_CLANG_HAS_EXTENSION
2220#define JSON_HEDLEY_CLANG_HAS_EXTENSION(extension) JSON_HEDLEY_HAS_EXTENSION(extension)
2222#if defined(JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE)
2223 #undef JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE
2225#define JSON_HEDLEY_CLANG_HAS_DECLSPEC_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute)
2227#if defined(JSON_HEDLEY_CLANG_HAS_WARNING)
2228 #undef JSON_HEDLEY_CLANG_HAS_WARNING
2230#define JSON_HEDLEY_CLANG_HAS_WARNING(warning) JSON_HEDLEY_HAS_WARNING(warning)
2237#include <type_traits>
2270template<
class Default,
2272 template<
class...>
class Op,
2280template<
class Default,
template<
class...>
class Op,
class... Args>
2287template<
template<
class...>
class Op,
class... Args>
2290template<
template<
class...>
class Op,
class... Args>
2293template<
template<
class...>
class Op,
class... Args>
2296template<
class Default,
template<
class...>
class Op,
class... Args>
2299template<
class Default,
template<
class...>
class Op,
class... Args>
2302template<
class Expected,
template<
class...>
class Op,
class... Args>
2305template<
class To,
template<
class...>
class Op,
class... Args>
2307 std::is_convertible<
detected_t<Op, Args...>, To>;
2316#if !defined(JSON_SKIP_UNSUPPORTED_COMPILER_CHECK)
2317 #if defined(__clang__)
2318 #if (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__) < 30400
2319 #error "unsupported Clang version - see https://github.com/nlohmann/json#supported-compilers"
2321 #elif defined(__GNUC__) && !(defined(__ICC) || defined(__INTEL_COMPILER))
2322 #if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) < 40800
2323 #error "unsupported GCC version - see https://github.com/nlohmann/json#supported-compilers"
2330#if !defined(JSON_HAS_CPP_20) && !defined(JSON_HAS_CPP_17) && !defined(JSON_HAS_CPP_14) && !defined(JSON_HAS_CPP_11)
2331 #if (defined(__cplusplus) && __cplusplus >= 202002L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 202002L)
2332 #define JSON_HAS_CPP_20
2333 #define JSON_HAS_CPP_17
2334 #define JSON_HAS_CPP_14
2335 #elif (defined(__cplusplus) && __cplusplus >= 201703L) || (defined(_HAS_CXX17) && _HAS_CXX17 == 1)
2336 #define JSON_HAS_CPP_17
2337 #define JSON_HAS_CPP_14
2338 #elif (defined(__cplusplus) && __cplusplus >= 201402L) || (defined(_HAS_CXX14) && _HAS_CXX14 == 1)
2339 #define JSON_HAS_CPP_14
2342 #define JSON_HAS_CPP_11
2345#if !defined(JSON_HAS_FILESYSTEM) && !defined(JSON_HAS_EXPERIMENTAL_FILESYSTEM)
2346 #ifdef JSON_HAS_CPP_17
2347 #if defined(__cpp_lib_filesystem)
2348 #define JSON_HAS_FILESYSTEM 1
2349 #elif defined(__cpp_lib_experimental_filesystem)
2350 #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1
2351 #elif !defined(__has_include)
2352 #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1
2353 #elif __has_include(<filesystem>)
2354 #define JSON_HAS_FILESYSTEM 1
2355 #elif __has_include(<experimental/filesystem>)
2356 #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1
2360 #if defined(__MINGW32__) && defined(__GNUC__) && __GNUC__ == 8
2361 #undef JSON_HAS_FILESYSTEM
2362 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2366 #if defined(__GNUC__) && !defined(__clang__) && __GNUC__ < 8
2367 #undef JSON_HAS_FILESYSTEM
2368 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2372 #if defined(__clang_major__) && __clang_major__ < 7
2373 #undef JSON_HAS_FILESYSTEM
2374 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2378 #if defined(_MSC_VER) && _MSC_VER < 1914
2379 #undef JSON_HAS_FILESYSTEM
2380 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2384 #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED < 130000
2385 #undef JSON_HAS_FILESYSTEM
2386 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2390 #if defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED < 101500
2391 #undef JSON_HAS_FILESYSTEM
2392 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2397#ifndef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2398 #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 0
2401#ifndef JSON_HAS_FILESYSTEM
2402 #define JSON_HAS_FILESYSTEM 0
2405#ifndef JSON_HAS_THREE_WAY_COMPARISON
2406 #if defined(__cpp_lib_three_way_comparison) && __cpp_lib_three_way_comparison >= 201907L \
2407 && defined(__cpp_impl_three_way_comparison)&& __cpp_impl_three_way_comparison >= 201907L
2408 #define JSON_HAS_THREE_WAY_COMPARISON 1
2410 #define JSON_HAS_THREE_WAY_COMPARISON 0
2414#if JSON_HEDLEY_HAS_ATTRIBUTE(no_unique_address)
2415 #define JSON_NO_UNIQUE_ADDRESS [[no_unique_address]]
2417 #define JSON_NO_UNIQUE_ADDRESS
2421#if defined(__clang__)
2422 #pragma clang diagnostic push
2423 #pragma clang diagnostic ignored "-Wdocumentation"
2424 #pragma clang diagnostic ignored "-Wdocumentation-unknown-command"
2428#if (defined(__cpp_exceptions) || defined(__EXCEPTIONS) || defined(_CPPUNWIND)) && !defined(JSON_NOEXCEPTION)
2429 #define JSON_THROW(exception) throw exception
2430 #define JSON_TRY try
2431 #define JSON_CATCH(exception) catch(exception)
2432 #define JSON_INTERNAL_CATCH(exception) catch(exception)
2435 #define JSON_THROW(exception) std::abort()
2436 #define JSON_TRY if(true)
2437 #define JSON_CATCH(exception) if(false)
2438 #define JSON_INTERNAL_CATCH(exception) if(false)
2442#if defined(JSON_THROW_USER)
2444 #define JSON_THROW JSON_THROW_USER
2446#if defined(JSON_TRY_USER)
2448 #define JSON_TRY JSON_TRY_USER
2450#if defined(JSON_CATCH_USER)
2452 #define JSON_CATCH JSON_CATCH_USER
2453 #undef JSON_INTERNAL_CATCH
2454 #define JSON_INTERNAL_CATCH JSON_CATCH_USER
2456#if defined(JSON_INTERNAL_CATCH_USER)
2457 #undef JSON_INTERNAL_CATCH
2458 #define JSON_INTERNAL_CATCH JSON_INTERNAL_CATCH_USER
2462#if !defined(JSON_ASSERT)
2464 #define JSON_ASSERT(x) assert(x)
2468#if defined(JSON_TESTS_PRIVATE)
2469 #define JSON_PRIVATE_UNLESS_TESTED public
2471 #define JSON_PRIVATE_UNLESS_TESTED private
2479#define NLOHMANN_JSON_SERIALIZE_ENUM(ENUM_TYPE, ...) \
2480 template<typename BasicJsonType> \
2481 inline void to_json(BasicJsonType& j, const ENUM_TYPE& e) \
2483 static_assert(std::is_enum<ENUM_TYPE>::value, #ENUM_TYPE " must be an enum!"); \
2484 static const std::pair<ENUM_TYPE, BasicJsonType> m[] = __VA_ARGS__; \
2485 auto it = std::find_if(std::begin(m), std::end(m), \
2486 [e](const std::pair<ENUM_TYPE, BasicJsonType>& ej_pair) -> bool \
2488 return ej_pair.first == e; \
2490 j = ((it != std::end(m)) ? it : std::begin(m))->second; \
2492 template<typename BasicJsonType> \
2493 inline void from_json(const BasicJsonType& j, ENUM_TYPE& e) \
2495 static_assert(std::is_enum<ENUM_TYPE>::value, #ENUM_TYPE " must be an enum!"); \
2496 static const std::pair<ENUM_TYPE, BasicJsonType> m[] = __VA_ARGS__; \
2497 auto it = std::find_if(std::begin(m), std::end(m), \
2498 [&j](const std::pair<ENUM_TYPE, BasicJsonType>& ej_pair) -> bool \
2500 return ej_pair.second == j; \
2502 e = ((it != std::end(m)) ? it : std::begin(m))->first; \
2508#define NLOHMANN_BASIC_JSON_TPL_DECLARATION \
2509 template<template<typename, typename, typename...> class ObjectType, \
2510 template<typename, typename...> class ArrayType, \
2511 class StringType, class BooleanType, class NumberIntegerType, \
2512 class NumberUnsignedType, class NumberFloatType, \
2513 template<typename> class AllocatorType, \
2514 template<typename, typename = void> class JSONSerializer, \
2517#define NLOHMANN_BASIC_JSON_TPL \
2518 basic_json<ObjectType, ArrayType, StringType, BooleanType, \
2519 NumberIntegerType, NumberUnsignedType, NumberFloatType, \
2520 AllocatorType, JSONSerializer, BinaryType>
2524#define NLOHMANN_JSON_EXPAND( x ) x
2525#define NLOHMANN_JSON_GET_MACRO(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, _51, _52, _53, _54, _55, _56, _57, _58, _59, _60, _61, _62, _63, _64, NAME,...) NAME
2526#define NLOHMANN_JSON_PASTE(...) NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_GET_MACRO(__VA_ARGS__, \
2527 NLOHMANN_JSON_PASTE64, \
2528 NLOHMANN_JSON_PASTE63, \
2529 NLOHMANN_JSON_PASTE62, \
2530 NLOHMANN_JSON_PASTE61, \
2531 NLOHMANN_JSON_PASTE60, \
2532 NLOHMANN_JSON_PASTE59, \
2533 NLOHMANN_JSON_PASTE58, \
2534 NLOHMANN_JSON_PASTE57, \
2535 NLOHMANN_JSON_PASTE56, \
2536 NLOHMANN_JSON_PASTE55, \
2537 NLOHMANN_JSON_PASTE54, \
2538 NLOHMANN_JSON_PASTE53, \
2539 NLOHMANN_JSON_PASTE52, \
2540 NLOHMANN_JSON_PASTE51, \
2541 NLOHMANN_JSON_PASTE50, \
2542 NLOHMANN_JSON_PASTE49, \
2543 NLOHMANN_JSON_PASTE48, \
2544 NLOHMANN_JSON_PASTE47, \
2545 NLOHMANN_JSON_PASTE46, \
2546 NLOHMANN_JSON_PASTE45, \
2547 NLOHMANN_JSON_PASTE44, \
2548 NLOHMANN_JSON_PASTE43, \
2549 NLOHMANN_JSON_PASTE42, \
2550 NLOHMANN_JSON_PASTE41, \
2551 NLOHMANN_JSON_PASTE40, \
2552 NLOHMANN_JSON_PASTE39, \
2553 NLOHMANN_JSON_PASTE38, \
2554 NLOHMANN_JSON_PASTE37, \
2555 NLOHMANN_JSON_PASTE36, \
2556 NLOHMANN_JSON_PASTE35, \
2557 NLOHMANN_JSON_PASTE34, \
2558 NLOHMANN_JSON_PASTE33, \
2559 NLOHMANN_JSON_PASTE32, \
2560 NLOHMANN_JSON_PASTE31, \
2561 NLOHMANN_JSON_PASTE30, \
2562 NLOHMANN_JSON_PASTE29, \
2563 NLOHMANN_JSON_PASTE28, \
2564 NLOHMANN_JSON_PASTE27, \
2565 NLOHMANN_JSON_PASTE26, \
2566 NLOHMANN_JSON_PASTE25, \
2567 NLOHMANN_JSON_PASTE24, \
2568 NLOHMANN_JSON_PASTE23, \
2569 NLOHMANN_JSON_PASTE22, \
2570 NLOHMANN_JSON_PASTE21, \
2571 NLOHMANN_JSON_PASTE20, \
2572 NLOHMANN_JSON_PASTE19, \
2573 NLOHMANN_JSON_PASTE18, \
2574 NLOHMANN_JSON_PASTE17, \
2575 NLOHMANN_JSON_PASTE16, \
2576 NLOHMANN_JSON_PASTE15, \
2577 NLOHMANN_JSON_PASTE14, \
2578 NLOHMANN_JSON_PASTE13, \
2579 NLOHMANN_JSON_PASTE12, \
2580 NLOHMANN_JSON_PASTE11, \
2581 NLOHMANN_JSON_PASTE10, \
2582 NLOHMANN_JSON_PASTE9, \
2583 NLOHMANN_JSON_PASTE8, \
2584 NLOHMANN_JSON_PASTE7, \
2585 NLOHMANN_JSON_PASTE6, \
2586 NLOHMANN_JSON_PASTE5, \
2587 NLOHMANN_JSON_PASTE4, \
2588 NLOHMANN_JSON_PASTE3, \
2589 NLOHMANN_JSON_PASTE2, \
2590 NLOHMANN_JSON_PASTE1)(__VA_ARGS__))
2591#define NLOHMANN_JSON_PASTE2(func, v1) func(v1)
2592#define NLOHMANN_JSON_PASTE3(func, v1, v2) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE2(func, v2)
2593#define NLOHMANN_JSON_PASTE4(func, v1, v2, v3) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE3(func, v2, v3)
2594#define NLOHMANN_JSON_PASTE5(func, v1, v2, v3, v4) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE4(func, v2, v3, v4)
2595#define NLOHMANN_JSON_PASTE6(func, v1, v2, v3, v4, v5) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE5(func, v2, v3, v4, v5)
2596#define NLOHMANN_JSON_PASTE7(func, v1, v2, v3, v4, v5, v6) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE6(func, v2, v3, v4, v5, v6)
2597#define NLOHMANN_JSON_PASTE8(func, v1, v2, v3, v4, v5, v6, v7) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE7(func, v2, v3, v4, v5, v6, v7)
2598#define NLOHMANN_JSON_PASTE9(func, v1, v2, v3, v4, v5, v6, v7, v8) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE8(func, v2, v3, v4, v5, v6, v7, v8)
2599#define NLOHMANN_JSON_PASTE10(func, v1, v2, v3, v4, v5, v6, v7, v8, v9) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE9(func, v2, v3, v4, v5, v6, v7, v8, v9)
2600#define NLOHMANN_JSON_PASTE11(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE10(func, v2, v3, v4, v5, v6, v7, v8, v9, v10)
2601#define NLOHMANN_JSON_PASTE12(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE11(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11)
2602#define NLOHMANN_JSON_PASTE13(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE12(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12)
2603#define NLOHMANN_JSON_PASTE14(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE13(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13)
2604#define NLOHMANN_JSON_PASTE15(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE14(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14)
2605#define NLOHMANN_JSON_PASTE16(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE15(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15)
2606#define NLOHMANN_JSON_PASTE17(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE16(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16)
2607#define NLOHMANN_JSON_PASTE18(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE17(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17)
2608#define NLOHMANN_JSON_PASTE19(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE18(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18)
2609#define NLOHMANN_JSON_PASTE20(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE19(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19)
2610#define NLOHMANN_JSON_PASTE21(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE20(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20)
2611#define NLOHMANN_JSON_PASTE22(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE21(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21)
2612#define NLOHMANN_JSON_PASTE23(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE22(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22)
2613#define NLOHMANN_JSON_PASTE24(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE23(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23)
2614#define NLOHMANN_JSON_PASTE25(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE24(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24)
2615#define NLOHMANN_JSON_PASTE26(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE25(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25)
2616#define NLOHMANN_JSON_PASTE27(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE26(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26)
2617#define NLOHMANN_JSON_PASTE28(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE27(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27)
2618#define NLOHMANN_JSON_PASTE29(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE28(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28)
2619#define NLOHMANN_JSON_PASTE30(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE29(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29)
2620#define NLOHMANN_JSON_PASTE31(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE30(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30)
2621#define NLOHMANN_JSON_PASTE32(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE31(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31)
2622#define NLOHMANN_JSON_PASTE33(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE32(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32)
2623#define NLOHMANN_JSON_PASTE34(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE33(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33)
2624#define NLOHMANN_JSON_PASTE35(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE34(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34)
2625#define NLOHMANN_JSON_PASTE36(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE35(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35)
2626#define NLOHMANN_JSON_PASTE37(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE36(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36)
2627#define NLOHMANN_JSON_PASTE38(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE37(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37)
2628#define NLOHMANN_JSON_PASTE39(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE38(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38)
2629#define NLOHMANN_JSON_PASTE40(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE39(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39)
2630#define NLOHMANN_JSON_PASTE41(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE40(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40)
2631#define NLOHMANN_JSON_PASTE42(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE41(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41)
2632#define NLOHMANN_JSON_PASTE43(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE42(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42)
2633#define NLOHMANN_JSON_PASTE44(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE43(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43)
2634#define NLOHMANN_JSON_PASTE45(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE44(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44)
2635#define NLOHMANN_JSON_PASTE46(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE45(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45)
2636#define NLOHMANN_JSON_PASTE47(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE46(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46)
2637#define NLOHMANN_JSON_PASTE48(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE47(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47)
2638#define NLOHMANN_JSON_PASTE49(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE48(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48)
2639#define NLOHMANN_JSON_PASTE50(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE49(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49)
2640#define NLOHMANN_JSON_PASTE51(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE50(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50)
2641#define NLOHMANN_JSON_PASTE52(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE51(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51)
2642#define NLOHMANN_JSON_PASTE53(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE52(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52)
2643#define NLOHMANN_JSON_PASTE54(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE53(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53)
2644#define NLOHMANN_JSON_PASTE55(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE54(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54)
2645#define NLOHMANN_JSON_PASTE56(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE55(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55)
2646#define NLOHMANN_JSON_PASTE57(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE56(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56)
2647#define NLOHMANN_JSON_PASTE58(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE57(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57)
2648#define NLOHMANN_JSON_PASTE59(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE58(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58)
2649#define NLOHMANN_JSON_PASTE60(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE59(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59)
2650#define NLOHMANN_JSON_PASTE61(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE60(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60)
2651#define NLOHMANN_JSON_PASTE62(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE61(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61)
2652#define NLOHMANN_JSON_PASTE63(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE62(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62)
2653#define NLOHMANN_JSON_PASTE64(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62, v63) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE63(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62, v63)
2655#define NLOHMANN_JSON_TO(v1) nlohmann_json_j[#v1] = nlohmann_json_t.v1;
2656#define NLOHMANN_JSON_FROM(v1) nlohmann_json_j.at(#v1).get_to(nlohmann_json_t.v1);
2657#define NLOHMANN_JSON_FROM_WITH_DEFAULT(v1) nlohmann_json_t.v1 = nlohmann_json_j.value(#v1, nlohmann_json_default_obj.v1);
2664#define NLOHMANN_DEFINE_TYPE_INTRUSIVE(Type, ...) \
2665 friend void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
2666 friend void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) }
2668#define NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(Type, ...) \
2669 friend void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
2670 friend void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { Type nlohmann_json_default_obj; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) }
2677#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Type, ...) \
2678 inline void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
2679 inline void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) }
2681#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(Type, ...) \
2682 inline void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
2683 inline void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { Type nlohmann_json_default_obj; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) }
2692#define NLOHMANN_CAN_CALL_STD_FUNC_IMPL(std_name) \
2693 namespace detail { \
2694 using std::std_name; \
2696 template<typename... T> \
2697 using result_of_##std_name = decltype(std_name(std::declval<T>()...)); \
2700 namespace detail2 { \
2701 struct std_name##_tag \
2705 template<typename... T> \
2706 std_name##_tag std_name(T&&...); \
2708 template<typename... T> \
2709 using result_of_##std_name = decltype(std_name(std::declval<T>()...)); \
2711 template<typename... T> \
2712 struct would_call_std_##std_name \
2714 static constexpr auto const value = ::nlohmann::detail:: \
2715 is_detected_exact<std_name##_tag, result_of_##std_name, T...>::value; \
2719 template<typename... T> \
2720 struct would_call_std_##std_name : detail2::would_call_std_##std_name<T...> \
2724#ifndef JSON_USE_IMPLICIT_CONVERSIONS
2725 #define JSON_USE_IMPLICIT_CONVERSIONS 1
2728#if JSON_USE_IMPLICIT_CONVERSIONS
2729 #define JSON_EXPLICIT
2731 #define JSON_EXPLICIT explicit
2734#ifndef JSON_DIAGNOSTICS
2735 #define JSON_DIAGNOSTICS 0
2757template<
typename StringType>
2759 const StringType& t)
2762 for (
auto pos = s.find(f);
2763 pos != StringType::npos;
2764 s.replace(pos, f.size(), t),
2765 pos = s.find(f, pos + t.size()))
2776template<
typename StringType>
2791template<
typename StringType>
2792static void unescape(StringType& s)
2821 constexpr operator size_t()
const
2836#include <type_traits>
2848using uncvref_t =
typename std::remove_cv<typename std::remove_reference<T>::type>::type;
2850#ifdef JSON_HAS_CPP_14
2861template<
bool B,
typename T =
void>
2888template <
typename T, T... Ints>
2892 static constexpr std::size_t
size() noexcept
2894 return sizeof...(Ints);
2903template <
size_t... Ints>
2906namespace utility_internal
2909template <
typename Seq,
size_t SeqSize,
size_t Rem>
2913template <
typename T, T... Ints,
size_t SeqSize>
2919template <
typename T, T... Ints,
size_t SeqSize>
2927template <
typename T,
size_t N>
2934template <
typename T>
2949template <
typename T, T N>
2965template <
typename... Ts>
2983#ifndef JSON_HAS_CPP_17
2985 template<
typename T>
2997#include <type_traits>
3018template<
typename It,
typename =
void>
3021template<
typename It>
3025 typename It::reference, typename It::iterator_category >>
3036template<
typename T,
typename =
void>
3086#ifndef INCLUDE_NLOHMANN_JSON_FWD_HPP_
3087#define INCLUDE_NLOHMANN_JSON_FWD_HPP_
3109template<
typename T =
void,
typename SFINAE =
void>
3110struct adl_serializer;
3114template<
template<
typename U,
typename V,
typename... Args>
class ObjectType =
3116 template<
typename U,
typename... Args>
class ArrayType = std::vector,
3117 class StringType = std::string,
class BooleanType = bool,
3118 class NumberIntegerType = std::int64_t,
3119 class NumberUnsignedType = std::uint64_t,
3120 class NumberFloatType = double,
3121 template<
typename U>
class AllocatorType = std::allocator,
3122 template<
typename T,
typename SFINAE =
void>
class JSONSerializer =
3124 class BinaryType = std::vector<std::uint8_t>>
3129template<
typename BasicJsonType>
3140template<
class Key,
class T,
class IgnoredLess,
class Allocator>
3185template<
typename BasicJsonContext>
3187 std::integral_constant < bool,
3188 is_basic_json<typename std::remove_cv<typename std::remove_pointer<BasicJsonContext>::type>::type>::value
3189 || std::is_same<BasicJsonContext, std::nullptr_t>::value >
3230template<
typename T,
typename... Args>
3233template<
typename T,
typename... Args>
3236template<
typename T,
typename U>
3240template<
typename BasicJsonType,
typename T,
typename =
void>
3247template <
typename BasicJsonType,
typename T>
3253template<
typename BasicJsonType,
typename T>
3256 using serializer =
typename BasicJsonType::template json_serializer<T, void>;
3260 const BasicJsonType&, T&>::value;
3265template<
typename BasicJsonType,
typename T,
typename =
void>
3268template<
typename BasicJsonType,
typename T>
3271 using serializer =
typename BasicJsonType::template json_serializer<T, void>;
3275 const BasicJsonType&>::value;
3280template<
typename BasicJsonType,
typename T,
typename =
void>
3283template<
typename BasicJsonType,
typename T>
3286 using serializer =
typename BasicJsonType::template json_serializer<T, void>;
3297struct has_key_compare : std::integral_constant<bool, is_detected<detect_key_compare, T>::value> {};
3300template<
typename BasicJsonType>
3305 using type =
typename std::conditional < has_key_compare<object_t>::value,
3309template<
typename BasicJsonType>
3319template<
class B,
class... Bn>
3321: std::conditional<bool(B::value), conjunction<Bn...>, B>::type {};
3324template<
class B>
struct negation : std::integral_constant < bool, !B::value > { };
3329template <
typename T>
3332template <
typename T1,
typename T2>
3334 :
conjunction<is_default_constructible<T1>, is_default_constructible<T2>> {};
3336template <
typename T1,
typename T2>
3338 :
conjunction<is_default_constructible<T1>, is_default_constructible<T2>> {};
3340template <
typename... Ts>
3342 :
conjunction<is_default_constructible<Ts>...> {};
3344template <
typename... Ts>
3346 :
conjunction<is_default_constructible<Ts>...> {};
3349template <
typename T,
typename... Args>
3352template <
typename T1,
typename T2>
3355template <
typename T1,
typename T2>
3358template <
typename... Ts>
3361template <
typename... Ts>
3365template<
typename T,
typename =
void>
3387 using t_ref =
typename std::add_lvalue_reference<T>::type;
3395 static constexpr auto is_iterator_begin =
3399 static constexpr bool value = !std::is_same<iterator, nonesuch>::value && !std::is_same<sentinel, nonesuch>::value && is_iterator_begin;
3412template<
typename T,
typename =
void>
3418template<
typename BasicJsonType,
typename CompatibleObjectType,
3422template<
typename BasicJsonType,
typename CompatibleObjectType>
3424 BasicJsonType, CompatibleObjectType,
3426 is_detected<key_type_t, CompatibleObjectType>::value >>
3433 typename CompatibleObjectType::key_type>::value &&
3435 typename CompatibleObjectType::mapped_type>::value;
3438template<
typename BasicJsonType,
typename CompatibleObjectType>
3442template<
typename BasicJsonType,
typename ConstructibleObjectType,
3446template<
typename BasicJsonType,
typename ConstructibleObjectType>
3448 BasicJsonType, ConstructibleObjectType,
3450 is_detected<key_type_t, ConstructibleObjectType>::value >>
3456 (std::is_move_assignable<ConstructibleObjectType>::value ||
3457 std::is_copy_assignable<ConstructibleObjectType>::value) &&
3459 typename object_t::key_type>::value &&
3461 typename object_t::mapped_type,
3462 typename ConstructibleObjectType::mapped_type >::value)) ||
3464 typename ConstructibleObjectType::mapped_type>::value ||
3467 typename ConstructibleObjectType::mapped_type >::value);
3470template<
typename BasicJsonType,
typename ConstructibleObjectType>
3473 ConstructibleObjectType> {};
3475template<
typename BasicJsonType,
typename CompatibleStringType>
3482template<
typename BasicJsonType,
typename ConstructibleStringType>
3486#ifdef __INTEL_COMPILER
3487 using laundered_type =
decltype(std::declval<ConstructibleStringType>());
3494 typename BasicJsonType::string_t>
::value;
3497template<
typename BasicJsonType,
typename CompatibleArrayType,
typename =
void>
3500template<
typename BasicJsonType,
typename CompatibleArrayType>
3502 BasicJsonType, CompatibleArrayType,
3505 is_iterator_traits<iterator_traits<detected_t<iterator_t, CompatibleArrayType>>>::value&&
3508 !std::is_same<CompatibleArrayType, detected_t<range_value_t, CompatibleArrayType>>::value >>
3515template<
typename BasicJsonType,
typename CompatibleArrayType>
3519template<
typename BasicJsonType,
typename ConstructibleArrayType,
typename =
void>
3522template<
typename BasicJsonType,
typename ConstructibleArrayType>
3524 BasicJsonType, ConstructibleArrayType,
3526 typename BasicJsonType::value_type>::value >>
3527 : std::true_type {};
3529template<
typename BasicJsonType,
typename ConstructibleArrayType>
3531 BasicJsonType, ConstructibleArrayType,
3533 typename BasicJsonType::value_type>::value&&
3536(std::is_move_assignable<ConstructibleArrayType>::value ||
3537 std::is_copy_assignable<ConstructibleArrayType>::value)&&
3538is_detected<iterator_t, ConstructibleArrayType>::value&&
3539is_iterator_traits<iterator_traits<detected_t<iterator_t, ConstructibleArrayType>>>::value&&
3540is_detected<range_value_t, ConstructibleArrayType>::value&&
3543!std::is_same<ConstructibleArrayType, detected_t<range_value_t, ConstructibleArrayType>>::value&&
3545 detected_t<range_value_t, ConstructibleArrayType >>::value >>
3551 typename BasicJsonType::array_t::value_type>::value ||
3559template<
typename BasicJsonType,
typename ConstructibleArrayType>
3563template<
typename RealIntegerType,
typename CompatibleNumberIntegerType,
3567template<
typename RealIntegerType,
typename CompatibleNumberIntegerType>
3569 RealIntegerType, CompatibleNumberIntegerType,
3571 std::is_integral<CompatibleNumberIntegerType>::value&&
3572 !std::is_same<bool, CompatibleNumberIntegerType>::value >>
3580 CompatibleNumberIntegerType>::value &&
3581 CompatibleLimits::is_integer &&
3582 RealLimits::is_signed == CompatibleLimits::is_signed;
3585template<
typename RealIntegerType,
typename CompatibleNumberIntegerType>
3588 CompatibleNumberIntegerType> {};
3590template<
typename BasicJsonType,
typename CompatibleType,
typename =
void>
3593template<
typename BasicJsonType,
typename CompatibleType>
3595 BasicJsonType, CompatibleType,
3602template<
typename BasicJsonType,
typename CompatibleType>
3606template<
typename T1,
typename T2>
3609template<
typename T1,
typename... Args>
3612template<
typename BasicJsonType,
typename T>
3615template<
typename BasicJsonType>
3618template<
typename BasicJsonType>
3623template<
template <
typename...>
class Primary,
typename T>
3626template<
template <
typename...>
class Primary,
typename... Args>
3633template<
typename Compare,
typename A,
typename B,
typename =
void>
3636template<
typename Compare,
typename A,
typename B>
3638decltype(
std::declval<Compare>()(std::declval<A>(), std::declval<B>())),
3639decltype(std::declval<Compare>()(std::declval<B>(), std::declval<A>()))
3640>> : std::true_type {};
3643template<
typename BasicJsonType,
typename KeyType>
3645 typename BasicJsonType::object_comparator_t,
3658template<
typename BasicJsonType,
typename KeyTypeCVRef,
bool RequireTransparentComparator =
true,
3662 && !(ExcludeObjectKeyType && std::is_same<KeyType,
3663 typename BasicJsonType::object_t::key_type>::value)
3664 && (!RequireTransparentComparator ||
is_detected <
3666 typename BasicJsonType::object_comparator_t >::value)
3670 std::false_type >::type;
3672template<
typename ObjectType,
typename KeyType>
3676template<
typename BasicJsonType,
typename KeyType>
3680 typename BasicJsonType::object_t, KeyType >::value,
3682 std::false_type >::type;
3686template <
typename T>
3696 template <
typename C>
static one test(
decltype(&C::capacity) ) ;
3699 enum {
value =
sizeof(test<T>(
nullptr)) ==
sizeof(
char) };
3703template < typename T, typename U, enable_if_t < !std::is_same<T, U>::value,
int > = 0 >
3706 return static_cast<T
>(
value);
3709template<typename T, typename U, enable_if_t<std::is_same<T, U>::value,
int> = 0>
3740template<
typename... Args>
3741inline std::size_t
concat_length(
const char* cstr, Args&& ... rest);
3743template<
typename StringType,
typename... Args>
3744inline std::size_t
concat_length(
const StringType& str, Args&& ... rest);
3746template<
typename... Args>
3752template<
typename... Args>
3756 return ::strlen(cstr) +
concat_length(std::forward<Args>(rest)...);
3759template<
typename StringType,
typename... Args>
3762 return str.size() +
concat_length(std::forward<Args>(rest)...);
3765template<
typename OutStringType>
3769template<
typename StringType,
typename Arg>
3772template<
typename StringType,
typename Arg>
3775template<
typename StringType,
typename Arg>
3778template<
typename StringType,
typename Arg>
3781template<
typename StringType,
typename Arg>
3782using string_can_append_iter =
decltype(std::declval<StringType&>().append(std::declval<const Arg&>().begin(), std::declval<const Arg&>().end()));
3784template<
typename StringType,
typename Arg>
3787template<
typename StringType,
typename Arg>
3788using string_can_append_data =
decltype(std::declval<StringType&>().append(std::declval<const Arg&>().data(), std::declval<const Arg&>().size()));
3790template<
typename StringType,
typename Arg>
3793template <
typename OutStringType,
typename Arg,
typename... Args,
3796inline void concat_into(OutStringType& out, Arg && arg, Args && ... rest);
3798template <
typename OutStringType,
typename Arg,
typename... Args,
3802inline void concat_into(OutStringType& out,
const Arg& arg, Args && ... rest);
3804template <
typename OutStringType,
typename Arg,
typename... Args,
3809inline void concat_into(OutStringType& out,
const Arg& arg, Args && ... rest);
3811template<
typename OutStringType,
typename Arg,
typename... Args,
3813inline void concat_into(OutStringType& out, Arg && arg, Args && ... rest)
3815 out.append(std::forward<Arg>(arg));
3819template <
typename OutStringType,
typename Arg,
typename... Args,
3820 enable_if_t < !detect_string_can_append<OutStringType, Arg>::value
3821 && detect_string_can_append_op<OutStringType, Arg>::value,
int > >
3822inline void concat_into(OutStringType& out, Arg&& arg, Args&& ... rest)
3824 out += std::forward<Arg>(arg);
3828template <
typename OutStringType,
typename Arg,
typename... Args,
3829 enable_if_t < !detect_string_can_append<OutStringType, Arg>::value
3830 && !detect_string_can_append_op<OutStringType, Arg>::value
3831 && detect_string_can_append_iter<OutStringType, Arg>::value,
int > >
3832inline void concat_into(OutStringType& out,
const Arg& arg, Args&& ... rest)
3834 out.append(arg.begin(), arg.end());
3838template <
typename OutStringType,
typename Arg,
typename... Args,
3839 enable_if_t < !detect_string_can_append<OutStringType, Arg>::value
3840 && !detect_string_can_append_op<OutStringType, Arg>::value
3841 && !detect_string_can_append_iter<OutStringType, Arg>::value
3842 && detect_string_can_append_data<OutStringType, Arg>::value,
int > >
3843inline void concat_into(OutStringType& out,
const Arg& arg, Args&& ... rest)
3845 out.append(arg.data(), arg.size());
3849template<
typename OutStringType = std::string,
typename... Args>
3877 const char*
what() const noexcept
override
3887 exception(
int id_, const
char* what_arg) :
id(id_), m(what_arg) {}
3889 static std::string
name(
const std::string& ename,
int id_)
3899 template<
typename BasicJsonType>
3903 std::vector<std::string> tokens;
3904 for (
const auto* current = leaf_element; current !=
nullptr && current->m_parent !=
nullptr; current = current->m_parent)
3906 switch (current->m_parent->type())
3910 for (std::size_t i = 0; i < current->m_parent->m_value.array->size(); ++i)
3912 if (¤t->m_parent->m_value.array->operator[](i) == current)
3923 for (
const auto& element : *current->m_parent->m_value.object)
3925 if (&element.second == current)
3927 tokens.emplace_back(element.first.c_str());
3952 auto str = std::accumulate(tokens.rbegin(), tokens.rend(), std::string{},
3953 [](
const std::string & a,
const std::string & b)
3955 return concat(a,
'/', detail::escape(b));
3957 return concat(
'(', str,
") ");
3959 static_cast<void>(leaf_element);
3966 std::runtime_error m;
3983 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
3991 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
3992 static parse_error create(
int id_, std::size_t byte_,
const std::string& what_arg, BasicJsonContext context)
3997 return {id_, byte_, w.c_str()};
4012 parse_error(
int id_, std::size_t byte_,
const char* what_arg)
4015 static std::string position_string(
const position_t& pos)
4027 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
4031 return {id_, w.c_str()};
4045 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
4049 return {id_, w.c_str()};
4062 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
4066 return {id_, w.c_str()};
4079 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
4083 return {id_, w.c_str()};
4117#if JSON_HAS_EXPERIMENTAL_FILESYSTEM
4118#include <experimental/filesystem>
4121namespace std_fs = std::experimental::filesystem;
4123#elif JSON_HAS_FILESYSTEM
4124#include <filesystem>
4127namespace std_fs = std::filesystem;
4135template<
typename BasicJsonType>
4136void from_json(
const BasicJsonType& j,
typename std::nullptr_t& n)
4146template <
typename BasicJsonType,
typename ArithmeticType,
4147 enable_if_t < std::is_arithmetic<ArithmeticType>::value&&
4148 !std::is_same<ArithmeticType, typename BasicJsonType::boolean_t>::value,
4152 switch (
static_cast<value_t>(j))
4156 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_unsigned_t*>());
4161 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_integer_t*>());
4166 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_float_t*>());
4182template<
typename BasicJsonType>
4183void from_json(
const BasicJsonType& j,
typename BasicJsonType::boolean_t& b)
4189 b = *j.template get_ptr<const typename BasicJsonType::boolean_t*>();
4192template<
typename BasicJsonType>
4193void from_json(
const BasicJsonType& j,
typename BasicJsonType::string_t& s)
4199 s = *j.template get_ptr<const typename BasicJsonType::string_t*>();
4203 typename BasicJsonType,
typename StringType,
4205 std::is_assignable<StringType&, const typename BasicJsonType::string_t>::value
4206 && !std::is_same<typename BasicJsonType::string_t, StringType>::value
4207 && !is_json_ref<StringType>::value,
int > = 0 >
4215 s = *j.template get_ptr<const typename BasicJsonType::string_t*>();
4218template<
typename BasicJsonType>
4219void from_json(
const BasicJsonType& j,
typename BasicJsonType::number_float_t& val)
4224template<
typename BasicJsonType>
4225void from_json(
const BasicJsonType& j,
typename BasicJsonType::number_unsigned_t& val)
4230template<
typename BasicJsonType>
4231void from_json(
const BasicJsonType& j,
typename BasicJsonType::number_integer_t& val)
4236template<
typename BasicJsonType,
typename EnumType,
4237 enable_if_t<std::is_enum<EnumType>::value,
int> = 0>
4240 typename std::underlying_type<EnumType>::type val;
4242 e =
static_cast<EnumType
>(val);
4246template<
typename BasicJsonType,
typename T,
typename Allocator,
4247 enable_if_t<is_getable<BasicJsonType, T>::value,
int> = 0>
4248void from_json(
const BasicJsonType& j, std::forward_list<T, Allocator>& l)
4255 std::transform(j.rbegin(), j.rend(),
4256 std::front_inserter(l), [](
const BasicJsonType & i)
4258 return i.template get<T>();
4263template<
typename BasicJsonType,
typename T,
4264 enable_if_t<is_getable<BasicJsonType, T>::value,
int> = 0>
4272 std::transform(j.begin(), j.end(), std::begin(l),
4273 [](
const BasicJsonType & elem)
4275 return elem.template get<T>();
4279template<
typename BasicJsonType,
typename T, std::
size_t N>
4281->
decltype(j.template get<T>(), void())
4283 for (std::size_t i = 0; i < N; ++i)
4285 arr[i] = j.at(i).template get<T>();
4289template<
typename BasicJsonType>
4292 arr = *j.template get_ptr<const typename BasicJsonType::array_t*>();
4295template<
typename BasicJsonType,
typename T, std::
size_t N>
4298->
decltype(j.template get<T>(), void())
4300 for (std::size_t i = 0; i < N; ++i)
4302 arr[i] = j.at(i).template get<T>();
4306template<
typename BasicJsonType,
typename ConstructibleArrayType,
4308 std::is_assignable<ConstructibleArrayType&, ConstructibleArrayType>::value,
4312 arr.reserve(std::declval<typename ConstructibleArrayType::size_type>()),
4313 j.template get<typename ConstructibleArrayType::value_type>(),
4318 ConstructibleArrayType ret;
4319 ret.reserve(j.size());
4320 std::transform(j.begin(), j.end(),
4321 std::inserter(ret, end(ret)), [](
const BasicJsonType & i)
4325 return i.template get<typename ConstructibleArrayType::value_type>();
4327 arr = std::move(ret);
4330template<
typename BasicJsonType,
typename ConstructibleArrayType,
4332 std::is_assignable<ConstructibleArrayType&, ConstructibleArrayType>::value,
4339 ConstructibleArrayType ret;
4341 j.begin(), j.end(), std::inserter(ret, end(ret)),
4342 [](
const BasicJsonType & i)
4346 return i.template get<typename ConstructibleArrayType::value_type>();
4348 arr = std::move(ret);
4351template <
typename BasicJsonType,
typename ConstructibleArrayType,
4353 is_constructible_array_type<BasicJsonType, ConstructibleArrayType>::value&&
4354 !is_constructible_object_type<BasicJsonType, ConstructibleArrayType>::value&&
4356 !std::is_same<ConstructibleArrayType, typename BasicJsonType::binary_t>::value&&
4357 !is_basic_json<ConstructibleArrayType>::value,
4359auto from_json(
const BasicJsonType& j, ConstructibleArrayType& arr)
4361j.template get<typename ConstructibleArrayType::value_type>(),
4372template <
typename BasicJsonType,
typename T, std::size_t... Idx >
4376 return { { std::forward<BasicJsonType>(j).at(Idx).template get<T>()... } };
4379template <
typename BasicJsonType,
typename T, std::
size_t N >
4391template<
typename BasicJsonType>
4392void from_json(
const BasicJsonType& j,
typename BasicJsonType::binary_t& bin)
4399 bin = *j.template get_ptr<const typename BasicJsonType::binary_t*>();
4402template<
typename BasicJsonType,
typename ConstructibleObjectType,
4403 enable_if_t<is_constructible_object_type<BasicJsonType, ConstructibleObjectType>::value,
int> = 0>
4404void from_json(
const BasicJsonType& j, ConstructibleObjectType& obj)
4411 ConstructibleObjectType ret;
4412 const auto* inner_object = j.template get_ptr<const typename BasicJsonType::object_t*>();
4413 using value_type =
typename ConstructibleObjectType::value_type;
4415 inner_object->begin(), inner_object->end(),
4416 std::inserter(ret, ret.begin()),
4417 [](
typename BasicJsonType::object_t::value_type
const & p)
4419 return value_type(p.first, p.second.template get<typename ConstructibleObjectType::mapped_type>());
4421 obj = std::move(ret);
4428template <
typename BasicJsonType,
typename ArithmeticType,
4430 std::is_arithmetic<ArithmeticType>::value&&
4431 !std::is_same<ArithmeticType, typename BasicJsonType::number_unsigned_t>::value&&
4432 !std::is_same<ArithmeticType, typename BasicJsonType::number_integer_t>::value&&
4433 !std::is_same<ArithmeticType, typename BasicJsonType::number_float_t>::value&&
4434 !std::is_same<ArithmeticType, typename BasicJsonType::boolean_t>::value,
4438 switch (
static_cast<value_t>(j))
4442 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_unsigned_t*>());
4447 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_integer_t*>());
4452 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_float_t*>());
4457 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::boolean_t*>());
4472template<
typename BasicJsonType,
typename... Args, std::size_t... Idx>
4475 return std::make_tuple(std::forward<BasicJsonType>(j).at(Idx).
template get<Args>()...);
4478template <
typename BasicJsonType,
class A1,
class A2 >
4481 return {std::forward<BasicJsonType>(j).at(0).template get<A1>(),
4482 std::forward<BasicJsonType>(j).at(1).template get<A2>()};
4485template<
typename BasicJsonType,
typename A1,
typename A2>
4491template<
typename BasicJsonType,
typename... Args>
4497template<
typename BasicJsonType,
typename... Args>
4503template<
typename BasicJsonType,
typename TupleRelated>
4512 return from_json_tuple_impl(std::forward<BasicJsonType>(j), std::forward<TupleRelated>(t), priority_tag<3> {});
4515template <
typename BasicJsonType,
typename Key,
typename Value,
typename Compare,
typename Allocator,
4517 typename BasicJsonType::string_t, Key >::value >>
4518void from_json(
const BasicJsonType& j, std::map<Key, Value, Compare, Allocator>& m)
4525 for (
const auto& p : j)
4531 m.emplace(p.at(0).template get<Key>(), p.at(1).template get<Value>());
4535template <
typename BasicJsonType,
typename Key,
typename Value,
typename Hash,
typename KeyEqual,
typename Allocator,
4537 typename BasicJsonType::string_t, Key >::value >>
4538void from_json(
const BasicJsonType& j, std::unordered_map<Key, Value, Hash, KeyEqual, Allocator>& m)
4545 for (
const auto& p : j)
4551 m.emplace(p.at(0).template get<Key>(), p.at(1).template get<Value>());
4555#if JSON_HAS_FILESYSTEM || JSON_HAS_EXPERIMENTAL_FILESYSTEM
4556template<
typename BasicJsonType>
4557void from_json(
const BasicJsonType& j, std_fs::path& p)
4563 p = *j.template get_ptr<const typename BasicJsonType::string_t*>();
4569 template<
typename BasicJsonType,
typename T>
4571 noexcept(
noexcept(
from_json(j, std::forward<T>(val))))
4572 ->
decltype(
from_json(j, std::forward<T>(val)))
4574 return from_json(j, std::forward<T>(val));
4595#include <type_traits>
4620template<
typename string_type>
4635 using string_type =
typename std::remove_cv< typename std::remove_reference<decltype( std::declval<IteratorType>().
key() ) >::type >::type;
4639 IteratorType anchor;
4641 std::size_t array_index = 0;
4643 mutable std::size_t array_index_last = 0;
4651 : anchor(std::move(it))
4672 return anchor == o.anchor;
4678 return anchor != o.anchor;
4686 switch (anchor.m_object->type())
4691 if (array_index != array_index_last)
4694 array_index_last = array_index;
4696 return array_index_str;
4701 return anchor.key();
4718 typename IteratorType::reference
value()
const
4720 return anchor.value();
4729 typename IteratorType::reference container;
4734 : container(cont) {}
4751template<std::
size_t N,
typename IteratorType, enable_if_t<N == 0,
int> = 0>
4759template<std::
size_t N,
typename IteratorType, enable_if_t<N == 1,
int> = 0>
4773#if defined(__clang__)
4775 #pragma clang diagnostic push
4776 #pragma clang diagnostic ignored "-Wmismatched-tags"
4778template<
typename IteratorType>
4780 :
public std::integral_constant<std::size_t, 2> {};
4782template<std::
size_t N,
typename IteratorType>
4787 get<N>(std::declval <
4790#if defined(__clang__)
4791 #pragma clang diagnostic pop
4802#if JSON_HAS_EXPERIMENTAL_FILESYSTEM
4803#include <experimental/filesystem>
4806namespace std_fs = std::experimental::filesystem;
4808#elif JSON_HAS_FILESYSTEM
4809#include <filesystem>
4812namespace std_fs = std::filesystem;
4836 template<
typename BasicJsonType>
4837 static void construct(BasicJsonType& j,
typename BasicJsonType::boolean_t b)
noexcept
4839 j.m_value.destroy(j.m_type);
4842 j.assert_invariant();
4849 template<
typename BasicJsonType>
4850 static void construct(BasicJsonType& j,
const typename BasicJsonType::string_t& s)
4852 j.m_value.destroy(j.m_type);
4855 j.assert_invariant();
4858 template<
typename BasicJsonType>
4859 static void construct(BasicJsonType& j,
typename BasicJsonType::string_t&& s)
4861 j.m_value.destroy(j.m_type);
4863 j.m_value = std::move(s);
4864 j.assert_invariant();
4867 template <
typename BasicJsonType,
typename CompatibleStringType,
4870 static void construct(BasicJsonType& j,
const CompatibleStringType& str)
4872 j.m_value.destroy(j.m_type);
4874 j.m_value.string = j.template create<typename BasicJsonType::string_t>(str);
4875 j.assert_invariant();
4882 template<
typename BasicJsonType>
4883 static void construct(BasicJsonType& j,
const typename BasicJsonType::binary_t& b)
4885 j.m_value.destroy(j.m_type);
4887 j.m_value =
typename BasicJsonType::binary_t(b);
4888 j.assert_invariant();
4891 template<
typename BasicJsonType>
4892 static void construct(BasicJsonType& j,
typename BasicJsonType::binary_t&& b)
4894 j.m_value.destroy(j.m_type);
4896 j.m_value =
typename BasicJsonType::binary_t(std::move(b));
4897 j.assert_invariant();
4904 template<
typename BasicJsonType>
4905 static void construct(BasicJsonType& j,
typename BasicJsonType::number_float_t val)
noexcept
4907 j.m_value.destroy(j.m_type);
4910 j.assert_invariant();
4917 template<
typename BasicJsonType>
4918 static void construct(BasicJsonType& j,
typename BasicJsonType::number_unsigned_t val)
noexcept
4920 j.m_value.destroy(j.m_type);
4923 j.assert_invariant();
4930 template<
typename BasicJsonType>
4931 static void construct(BasicJsonType& j,
typename BasicJsonType::number_integer_t val)
noexcept
4933 j.m_value.destroy(j.m_type);
4936 j.assert_invariant();
4943 template<
typename BasicJsonType>
4944 static void construct(BasicJsonType& j,
const typename BasicJsonType::array_t& arr)
4946 j.m_value.destroy(j.m_type);
4950 j.assert_invariant();
4953 template<
typename BasicJsonType>
4954 static void construct(BasicJsonType& j,
typename BasicJsonType::array_t&& arr)
4956 j.m_value.destroy(j.m_type);
4958 j.m_value = std::move(arr);
4960 j.assert_invariant();
4963 template <
typename BasicJsonType,
typename CompatibleArrayType,
4966 static void construct(BasicJsonType& j,
const CompatibleArrayType& arr)
4971 j.m_value.destroy(j.m_type);
4973 j.m_value.array = j.template create<typename BasicJsonType::array_t>(begin(arr), end(arr));
4975 j.assert_invariant();
4978 template<
typename BasicJsonType>
4979 static void construct(BasicJsonType& j,
const std::vector<bool>& arr)
4981 j.m_value.destroy(j.m_type);
4984 j.m_value.array->reserve(arr.size());
4985 for (
const bool x : arr)
4987 j.m_value.array->push_back(x);
4988 j.set_parent(j.m_value.array->back());
4990 j.assert_invariant();
4993 template<
typename BasicJsonType,
typename T,
4995 static void construct(BasicJsonType& j,
const std::valarray<T>& arr)
4997 j.m_value.destroy(j.m_type);
5000 j.m_value.array->resize(arr.size());
5003 std::copy(std::begin(arr), std::end(arr), j.m_value.array->begin());
5006 j.assert_invariant();
5013 template<
typename BasicJsonType>
5014 static void construct(BasicJsonType& j,
const typename BasicJsonType::object_t& obj)
5016 j.m_value.destroy(j.m_type);
5020 j.assert_invariant();
5023 template<
typename BasicJsonType>
5024 static void construct(BasicJsonType& j,
typename BasicJsonType::object_t&& obj)
5026 j.m_value.destroy(j.m_type);
5028 j.m_value = std::move(obj);
5030 j.assert_invariant();
5033 template <
typename BasicJsonType,
typename CompatibleObjectType,
5035 static void construct(BasicJsonType& j,
const CompatibleObjectType& obj)
5040 j.m_value.destroy(j.m_type);
5042 j.m_value.object = j.template create<typename BasicJsonType::object_t>(begin(obj), end(obj));
5044 j.assert_invariant();
5052template<
typename BasicJsonType,
typename T,
5053 enable_if_t<std::is_same<T, typename BasicJsonType::boolean_t>::value,
int> = 0>
5059template<
typename BasicJsonType,
typename CompatibleString,
5060 enable_if_t<std::is_constructible<typename BasicJsonType::string_t, CompatibleString>::value,
int> = 0>
5061void to_json(BasicJsonType& j,
const CompatibleString& s)
5066template<
typename BasicJsonType>
5067void to_json(BasicJsonType& j,
typename BasicJsonType::string_t&& s)
5072template<
typename BasicJsonType,
typename FloatType,
5073 enable_if_t<std::is_floating_point<FloatType>::value,
int> = 0>
5074void to_json(BasicJsonType& j, FloatType val)
noexcept
5079template<
typename BasicJsonType,
typename CompatibleNumberUnsignedType,
5080 enable_if_t<is_compatible_integer_type<typename BasicJsonType::number_unsigned_t, CompatibleNumberUnsignedType>::value,
int> = 0>
5081void to_json(BasicJsonType& j, CompatibleNumberUnsignedType val)
noexcept
5086template<
typename BasicJsonType,
typename CompatibleNumberIntegerType,
5087 enable_if_t<is_compatible_integer_type<typename BasicJsonType::number_integer_t, CompatibleNumberIntegerType>::value,
int> = 0>
5088void to_json(BasicJsonType& j, CompatibleNumberIntegerType val)
noexcept
5093template<
typename BasicJsonType,
typename EnumType,
5094 enable_if_t<std::is_enum<EnumType>::value,
int> = 0>
5095void to_json(BasicJsonType& j, EnumType e)
noexcept
5097 using underlying_type =
typename std::underlying_type<EnumType>::type;
5101template<
typename BasicJsonType>
5102void to_json(BasicJsonType& j,
const std::vector<bool>& e)
5107template <
typename BasicJsonType,
typename CompatibleArrayType,
5108 enable_if_t < is_compatible_array_type<BasicJsonType,
5109 CompatibleArrayType>::value&&
5110 !is_compatible_object_type<BasicJsonType, CompatibleArrayType>::value&&
5112 !std::is_same<typename BasicJsonType::binary_t, CompatibleArrayType>::value&&
5113 !is_basic_json<CompatibleArrayType>::value,
5115void to_json(BasicJsonType& j,
const CompatibleArrayType& arr)
5120template<
typename BasicJsonType>
5121void to_json(BasicJsonType& j,
const typename BasicJsonType::binary_t& bin)
5126template<
typename BasicJsonType,
typename T,
5127 enable_if_t<std::is_convertible<T, BasicJsonType>::value,
int> = 0>
5128void to_json(BasicJsonType& j,
const std::valarray<T>& arr)
5133template<
typename BasicJsonType>
5134void to_json(BasicJsonType& j,
typename BasicJsonType::array_t&& arr)
5139template <
typename BasicJsonType,
typename CompatibleObjectType,
5140 enable_if_t < is_compatible_object_type<BasicJsonType, CompatibleObjectType>::value&& !is_basic_json<CompatibleObjectType>::value,
int > = 0 >
5141void to_json(BasicJsonType& j,
const CompatibleObjectType& obj)
5146template<
typename BasicJsonType>
5147void to_json(BasicJsonType& j,
typename BasicJsonType::object_t&& obj)
5153 typename BasicJsonType,
typename T, std::size_t N,
5154 enable_if_t < !std::is_constructible<
typename BasicJsonType::string_t,
5155 const T(&)[N]>::value,
5162template < typename BasicJsonType, typename T1, typename T2, enable_if_t < std::is_constructible<BasicJsonType, T1>::value&& std::is_constructible<BasicJsonType, T2>::value,
int > = 0 >
5163void to_json(BasicJsonType& j,
const std::pair<T1, T2>& p)
5165 j = { p.first, p.second };
5169template<
typename BasicJsonType,
typename T,
5170 enable_if_t<std::is_same<T, iteration_proxy_value<typename BasicJsonType::iterator>>::value,
int> = 0>
5173 j = { {b.key(), b.value()} };
5176template<
typename BasicJsonType,
typename Tuple, std::size_t... Idx>
5179 j = { std::get<Idx>(t)... };
5182template<typename BasicJsonType, typename T, enable_if_t<is_constructible_tuple<BasicJsonType, T>::value,
int > = 0>
5183void to_json(BasicJsonType& j,
const T& t)
5188#if JSON_HAS_FILESYSTEM || JSON_HAS_EXPERIMENTAL_FILESYSTEM
5189template<
typename BasicJsonType>
5190void to_json(BasicJsonType& j,
const std_fs::path& p)
5198 template<
typename BasicJsonType,
typename T>
5199 auto operator()(BasicJsonType& j, T&& val)
const noexcept(
noexcept(
to_json(j, std::forward<T>(val))))
5200 ->
decltype(
to_json(j, std::forward<T>(val)), void())
5202 return to_json(j, std::forward<T>(val));
5225template<
typename ValueType,
typename>
5230 template<
typename BasicJsonType,
typename TargetType = ValueType>
5231 static auto from_json(BasicJsonType && j, TargetType& val)
noexcept(
5240 template<
typename BasicJsonType,
typename TargetType = ValueType>
5250 template<
typename BasicJsonType,
typename TargetType = ValueType>
5251 static auto to_json(BasicJsonType& j, TargetType && val)
noexcept(
5272template<
typename BinaryType>
5297 , m_subtype(subtype_)
5298 , m_has_subtype(
true)
5304 , m_subtype(subtype_)
5305 , m_has_subtype(
true)
5310 return std::tie(
static_cast<const BinaryType&
>(*
this), m_subtype, m_has_subtype) ==
5311 std::tie(
static_cast<const BinaryType&
>(rhs), rhs.m_subtype, rhs.m_has_subtype);
5316 return !(rhs == *
this);
5323 m_subtype = subtype_;
5324 m_has_subtype =
true;
5331 return m_has_subtype ? m_subtype :
static_cast<subtype_type>(-1);
5338 return m_has_subtype;
5346 m_has_subtype =
false;
5351 bool m_has_subtype =
false;
5367#include <functional>
5380inline std::size_t
combine(std::size_t seed, std::size_t h)
noexcept
5382 seed ^= h + 0x9e3779b9 + (seed << 6U) + (seed >> 2U);
5397template<
typename BasicJsonType>
5398std::size_t
hash(
const BasicJsonType& j)
5400 using string_t =
typename BasicJsonType::string_t;
5401 using number_integer_t =
typename BasicJsonType::number_integer_t;
5402 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
5403 using number_float_t =
typename BasicJsonType::number_float_t;
5405 const auto type =
static_cast<std::size_t
>(j.type());
5408 case BasicJsonType::value_t::null:
5409 case BasicJsonType::value_t::discarded:
5414 case BasicJsonType::value_t::object:
5416 auto seed =
combine(type, j.size());
5417 for (
const auto& element : j.items())
5419 const auto h = std::hash<string_t> {}(element.key());
5426 case BasicJsonType::value_t::array:
5428 auto seed =
combine(type, j.size());
5429 for (
const auto& element : j)
5436 case BasicJsonType::value_t::string:
5438 const auto h = std::hash<string_t> {}(j.template get_ref<const string_t&>());
5442 case BasicJsonType::value_t::boolean:
5444 const auto h = std::hash<bool> {}(j.template get<bool>());
5448 case BasicJsonType::value_t::number_integer:
5450 const auto h = std::hash<number_integer_t> {}(j.template get<number_integer_t>());
5454 case BasicJsonType::value_t::number_unsigned:
5456 const auto h = std::hash<number_unsigned_t> {}(j.template get<number_unsigned_t>());
5460 case BasicJsonType::value_t::number_float:
5462 const auto h = std::hash<number_float_t> {}(j.template get<number_float_t>());
5466 case BasicJsonType::value_t::binary:
5468 auto seed =
combine(type, j.get_binary().size());
5469 const auto h = std::hash<bool> {}(j.get_binary().has_subtype());
5471 seed =
combine(seed,
static_cast<std::size_t
>(j.get_binary().subtype()));
5472 for (
const auto byte : j.get_binary())
5474 seed =
combine(seed, std::hash<std::uint8_t> {}(byte));
5517#include <type_traits>
5565 return std::fgetc(m_file);
5594 is->clear(is->rdstate() & std::ios::eofbit);
5599 : is(&i), sb(i.rdbuf())
5608 : is(rhs.is), sb(rhs.sb)
5619 auto res = sb->sbumpc();
5623 is->clear(is->rdstate() | std::ios::eofbit);
5630 std::istream* is =
nullptr;
5631 std::streambuf* sb =
nullptr;
5637template<
typename IteratorType>
5641 using char_type =
typename std::iterator_traits<IteratorType>::value_type;
5644 : current(
std::move(first)), end(
std::move(last))
5651 auto result = std::char_traits<char_type>::to_int_type(*current);
5652 std::advance(current, 1);
5656 return std::char_traits<char_type>::eof();
5660 IteratorType current;
5663 template<
typename BaseInputAdapter,
size_t T>
5668 return current == end;
5673template<
typename BaseInputAdapter,
size_t T>
5676template<
typename BaseInputAdapter>
5681 std::array<std::char_traits<char>::int_type, 4>& utf8_bytes,
5682 size_t& utf8_bytes_index,
5683 size_t& utf8_bytes_filled)
5685 utf8_bytes_index = 0;
5689 utf8_bytes[0] = std::char_traits<char>::eof();
5690 utf8_bytes_filled = 1;
5695 const auto wc = input.get_character();
5700 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
5701 utf8_bytes_filled = 1;
5703 else if (wc <= 0x7FF)
5705 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xC0u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x1Fu));
5706 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
5707 utf8_bytes_filled = 2;
5709 else if (wc <= 0xFFFF)
5711 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xE0u | ((
static_cast<unsigned int>(wc) >> 12u) & 0x0Fu));
5712 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x3Fu));
5713 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
5714 utf8_bytes_filled = 3;
5716 else if (wc <= 0x10FFFF)
5718 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xF0u | ((
static_cast<unsigned int>(wc) >> 18u) & 0x07u));
5719 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 12u) & 0x3Fu));
5720 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x3Fu));
5721 utf8_bytes[3] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
5722 utf8_bytes_filled = 4;
5727 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
5728 utf8_bytes_filled = 1;
5734template<
typename BaseInputAdapter>
5739 std::array<std::char_traits<char>::int_type, 4>& utf8_bytes,
5740 size_t& utf8_bytes_index,
5741 size_t& utf8_bytes_filled)
5743 utf8_bytes_index = 0;
5747 utf8_bytes[0] = std::char_traits<char>::eof();
5748 utf8_bytes_filled = 1;
5753 const auto wc = input.get_character();
5758 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
5759 utf8_bytes_filled = 1;
5761 else if (wc <= 0x7FF)
5763 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xC0u | ((
static_cast<unsigned int>(wc) >> 6u)));
5764 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
5765 utf8_bytes_filled = 2;
5767 else if (0xD800 > wc || wc >= 0xE000)
5769 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xE0u | ((
static_cast<unsigned int>(wc) >> 12u)));
5770 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x3Fu));
5771 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
5772 utf8_bytes_filled = 3;
5778 const auto wc2 =
static_cast<unsigned int>(input.get_character());
5779 const auto charcode = 0x10000u + (((
static_cast<unsigned int>(wc) & 0x3FFu) << 10u) | (wc2 & 0x3FFu));
5780 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xF0u | (charcode >> 18u));
5781 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((charcode >> 12u) & 0x3Fu));
5782 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((charcode >> 6u) & 0x3Fu));
5783 utf8_bytes[3] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (charcode & 0x3Fu));
5784 utf8_bytes_filled = 4;
5788 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
5789 utf8_bytes_filled = 1;
5797template<
typename BaseInputAdapter,
typename W
ideCharType>
5804 : base_adapter(base) {}
5809 if (utf8_bytes_index == utf8_bytes_filled)
5811 fill_buffer<sizeof(WideCharType)>();
5819 JSON_ASSERT(utf8_bytes_index < utf8_bytes_filled);
5820 return utf8_bytes[utf8_bytes_index++];
5824 BaseInputAdapter base_adapter;
5833 std::array<std::char_traits<char>::int_type, 4> utf8_bytes = {{0, 0, 0, 0}};
5836 std::size_t utf8_bytes_index = 0;
5838 std::size_t utf8_bytes_filled = 0;
5842template<
typename IteratorType,
typename Enable =
void>
5846 using char_type =
typename std::iterator_traits<iterator_type>::value_type;
5851 return adapter_type(std::move(first), std::move(last));
5865template<
typename IteratorType>
5869 using char_type =
typename std::iterator_traits<iterator_type>::value_type;
5880template<
typename IteratorType>
5884 return factory_type::create(first, last);
5891namespace container_input_adapter_factory_impl
5897template<
typename ContainerType,
typename Enable =
void>
5900template<
typename ContainerType>
5902 void_t<decltype(begin(
std::declval<ContainerType>()), end(std::declval<ContainerType>()))>>
5914template<
typename ContainerType>
5941template <
typename CharT,
5942 typename std::enable_if <
5943 std::is_pointer<CharT>::value&&
5944 !std::is_array<CharT>::value&&
5945 std::is_integral<typename std::remove_pointer<CharT>::type>::value&&
5946 sizeof(
typename std::remove_pointer<CharT>::type) == 1,
5950 auto length = std::strlen(
reinterpret_cast<const char*
>(b));
5951 const auto* ptr =
reinterpret_cast<const char*
>(b);
5955template<
typename T, std::
size_t N>
5967 template <
typename CharT,
5968 typename std::enable_if <
5969 std::is_pointer<CharT>::value&&
5970 std::is_integral<typename std::remove_pointer<CharT>::type>::value&&
5971 sizeof(
typename std::remove_pointer<CharT>::type) == 1,
5974 : ia(
reinterpret_cast<const char*
>(b),
reinterpret_cast<const char*
>(b) + l) {}
5976 template<
class IteratorType,
5977 typename std::enable_if<
5978 std::is_same<typename iterator_traits<IteratorType>::iterator_category, std::random_access_iterator_tag>::value,
5985 return std::move(ia);
6020template<
typename BasicJsonType>
6124 const std::string& last_token,
6151template<
typename BasicJsonType>
6167 : root(r), allow_exceptions(allow_exceptions_)
6179 handle_value(
nullptr);
6215 handle_value(std::move(val));
6221 ref_stack.push_back(handle_value(BasicJsonType::value_t::object));
6223 if (
JSON_HEDLEY_UNLIKELY(len !=
static_cast<std::size_t
>(-1) && len > ref_stack.back()->max_size()))
6234 object_element = &(ref_stack.back()->m_value.object->operator[](val));
6240 ref_stack.back()->set_parents();
6241 ref_stack.pop_back();
6247 ref_stack.push_back(handle_value(BasicJsonType::value_t::array));
6249 if (
JSON_HEDLEY_UNLIKELY(len !=
static_cast<std::size_t
>(-1) && len > ref_stack.back()->max_size()))
6259 ref_stack.back()->set_parents();
6260 ref_stack.pop_back();
6264 template<
class Exception>
6266 const Exception& ex)
6269 static_cast<void>(ex);
6270 if (allow_exceptions)
6289 template<
typename Value>
6291 BasicJsonType* handle_value(Value&& v)
6293 if (ref_stack.empty())
6295 root = BasicJsonType(std::forward<Value>(v));
6299 JSON_ASSERT(ref_stack.back()->is_array() || ref_stack.back()->is_object());
6301 if (ref_stack.back()->is_array())
6303 ref_stack.back()->m_value.array->emplace_back(std::forward<Value>(v));
6304 return &(ref_stack.back()->m_value.array->back());
6309 *object_element = BasicJsonType(std::forward<Value>(v));
6310 return object_element;
6314 BasicJsonType& root;
6316 std::vector<BasicJsonType*> ref_stack {};
6318 BasicJsonType* object_element =
nullptr;
6320 bool errored =
false;
6322 const bool allow_exceptions =
true;
6325template<
typename BasicJsonType>
6339 const bool allow_exceptions_ =
true)
6340 : root(r), callback(cb), allow_exceptions(allow_exceptions_)
6342 keep_stack.push_back(
true);
6354 handle_value(
nullptr);
6390 handle_value(std::move(val));
6397 const bool keep = callback(
static_cast<int>(ref_stack.size()), parse_event_t::object_start,
discarded);
6398 keep_stack.push_back(keep);
6400 auto val = handle_value(BasicJsonType::value_t::object,
true);
6401 ref_stack.push_back(val.second);
6404 if (ref_stack.back() &&
JSON_HEDLEY_UNLIKELY(len !=
static_cast<std::size_t
>(-1) && len > ref_stack.back()->max_size()))
6414 BasicJsonType k = BasicJsonType(val);
6417 const bool keep = callback(
static_cast<int>(ref_stack.size()), parse_event_t::key, k);
6418 key_keep_stack.push_back(keep);
6421 if (keep && ref_stack.back())
6423 object_element = &(ref_stack.back()->m_value.object->operator[](val) =
discarded);
6431 if (ref_stack.back())
6433 if (!callback(
static_cast<int>(ref_stack.size()) - 1, parse_event_t::object_end, *ref_stack.back()))
6440 ref_stack.back()->set_parents();
6446 ref_stack.pop_back();
6447 keep_stack.pop_back();
6449 if (!ref_stack.empty() && ref_stack.back() && ref_stack.back()->is_structured())
6452 for (
auto it = ref_stack.back()->begin(); it != ref_stack.back()->end(); ++it)
6454 if (it->is_discarded())
6456 ref_stack.back()->erase(it);
6467 const bool keep = callback(
static_cast<int>(ref_stack.size()), parse_event_t::array_start,
discarded);
6468 keep_stack.push_back(keep);
6470 auto val = handle_value(BasicJsonType::value_t::array,
true);
6471 ref_stack.push_back(val.second);
6474 if (ref_stack.back() &&
JSON_HEDLEY_UNLIKELY(len !=
static_cast<std::size_t
>(-1) && len > ref_stack.back()->max_size()))
6486 if (ref_stack.back())
6488 keep = callback(
static_cast<int>(ref_stack.size()) - 1, parse_event_t::array_end, *ref_stack.back());
6491 ref_stack.back()->set_parents();
6502 ref_stack.pop_back();
6503 keep_stack.pop_back();
6506 if (!keep && !ref_stack.empty() && ref_stack.back()->is_array())
6508 ref_stack.back()->m_value.array->pop_back();
6514 template<
class Exception>
6516 const Exception& ex)
6519 static_cast<void>(ex);
6520 if (allow_exceptions)
6548 template<
typename Value>
6549 std::pair<bool, BasicJsonType*> handle_value(Value&& v,
const bool skip_callback =
false)
6555 if (!keep_stack.back())
6557 return {
false,
nullptr};
6561 auto value = BasicJsonType(std::forward<Value>(v));
6564 const bool keep = skip_callback || callback(
static_cast<int>(ref_stack.size()), parse_event_t::value, value);
6569 return {
false,
nullptr};
6572 if (ref_stack.empty())
6574 root = std::move(value);
6575 return {
true, &root};
6580 if (!ref_stack.back())
6582 return {
false,
nullptr};
6586 JSON_ASSERT(ref_stack.back()->is_array() || ref_stack.back()->is_object());
6589 if (ref_stack.back()->is_array())
6591 ref_stack.back()->m_value.array->emplace_back(std::move(value));
6592 return {
true, &(ref_stack.back()->m_value.array->back())};
6599 const bool store_element = key_keep_stack.back();
6600 key_keep_stack.pop_back();
6604 return {
false,
nullptr};
6608 *object_element = std::move(value);
6609 return {
true, object_element};
6613 BasicJsonType& root;
6615 std::vector<BasicJsonType*> ref_stack {};
6617 std::vector<bool> keep_stack {};
6619 std::vector<bool> key_keep_stack {};
6621 BasicJsonType* object_element =
nullptr;
6623 bool errored =
false;
6627 const bool allow_exceptions =
true;
6629 BasicJsonType
discarded = BasicJsonType::value_t::discarded;
6632template<
typename BasicJsonType>
6719#include <initializer_list>
6739template<
typename BasicJsonType>
6773 return "<uninitialized>";
6775 return "true literal";
6777 return "false literal";
6779 return "null literal";
6781 return "string literal";
6785 return "number literal";
6799 return "<parse error>";
6801 return "end of input";
6803 return "'[', '{', or a literal";
6806 return "unknown token";
6816template<
typename BasicJsonType,
typename InputAdapterType>
6819 using number_integer_t =
typename BasicJsonType::number_integer_t;
6820 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
6821 using number_float_t =
typename BasicJsonType::number_float_t;
6822 using string_t =
typename BasicJsonType::string_t;
6823 using char_type =
typename InputAdapterType::char_type;
6824 using char_int_type =
typename std::char_traits<char_type>::int_type;
6829 explicit lexer(InputAdapterType&& adapter,
bool ignore_comments_ =
false) noexcept
6830 : ia(
std::move(adapter))
6831 , ignore_comments(ignore_comments_)
6832 , decimal_point_char(static_cast<char_int_type>(get_decimal_point()))
6849 static char get_decimal_point() noexcept
6851 const auto* loc = localeconv();
6853 return (loc->decimal_point ==
nullptr) ?
'.' : *(loc->decimal_point);
6881 const auto factors = { 12u, 8u, 4u, 0u };
6882 for (
const auto factor : factors)
6886 if (current >=
'0' && current <=
'9')
6888 codepoint +=
static_cast<int>((
static_cast<unsigned int>(current) - 0x30u) << factor);
6890 else if (current >=
'A' && current <=
'F')
6892 codepoint +=
static_cast<int>((
static_cast<unsigned int>(current) - 0x37u) << factor);
6894 else if (current >=
'a' && current <=
'f')
6896 codepoint +=
static_cast<int>((
static_cast<unsigned int>(current) - 0x57u) << factor);
6904 JSON_ASSERT(0x0000 <= codepoint && codepoint <= 0xFFFF);
6923 bool next_byte_in_range(std::initializer_list<char_int_type> ranges)
6925 JSON_ASSERT(ranges.size() == 2 || ranges.size() == 4 || ranges.size() == 6);
6928 for (
auto range = ranges.begin(); range != ranges.end(); ++range)
6937 error_message =
"invalid string: ill-formed UTF-8 byte";
6974 case std::char_traits<char_type>::eof():
6976 error_message =
"invalid string: missing closing quote";
6977 return token_type::parse_error;
6983 return token_type::value_string;
7027 const int codepoint1 = get_codepoint();
7028 int codepoint = codepoint1;
7032 error_message =
"invalid string: '\\u' must be followed by 4 hex digits";
7033 return token_type::parse_error;
7037 if (0xD800 <= codepoint1 && codepoint1 <= 0xDBFF)
7042 const int codepoint2 = get_codepoint();
7046 error_message =
"invalid string: '\\u' must be followed by 4 hex digits";
7047 return token_type::parse_error;
7054 codepoint =
static_cast<int>(
7056 (
static_cast<unsigned int>(codepoint1) << 10u)
7058 +
static_cast<unsigned int>(codepoint2)
7066 error_message =
"invalid string: surrogate U+D800..U+DBFF must be followed by U+DC00..U+DFFF";
7067 return token_type::parse_error;
7072 error_message =
"invalid string: surrogate U+D800..U+DBFF must be followed by U+DC00..U+DFFF";
7073 return token_type::parse_error;
7080 error_message =
"invalid string: surrogate U+DC00..U+DFFF must follow U+D800..U+DBFF";
7081 return token_type::parse_error;
7086 JSON_ASSERT(0x00 <= codepoint && codepoint <= 0x10FFFF);
7089 if (codepoint < 0x80)
7092 add(
static_cast<char_int_type
>(codepoint));
7094 else if (codepoint <= 0x7FF)
7097 add(
static_cast<char_int_type
>(0xC0u | (
static_cast<unsigned int>(codepoint) >> 6u)));
7098 add(
static_cast<char_int_type
>(0x80u | (
static_cast<unsigned int>(codepoint) & 0x3Fu)));
7100 else if (codepoint <= 0xFFFF)
7103 add(
static_cast<char_int_type
>(0xE0u | (
static_cast<unsigned int>(codepoint) >> 12u)));
7104 add(
static_cast<char_int_type
>(0x80u | ((
static_cast<unsigned int>(codepoint) >> 6u) & 0x3Fu)));
7105 add(
static_cast<char_int_type
>(0x80u | (
static_cast<unsigned int>(codepoint) & 0x3Fu)));
7110 add(
static_cast<char_int_type
>(0xF0u | (
static_cast<unsigned int>(codepoint) >> 18u)));
7111 add(
static_cast<char_int_type
>(0x80u | ((
static_cast<unsigned int>(codepoint) >> 12u) & 0x3Fu)));
7112 add(
static_cast<char_int_type
>(0x80u | ((
static_cast<unsigned int>(codepoint) >> 6u) & 0x3Fu)));
7113 add(
static_cast<char_int_type
>(0x80u | (
static_cast<unsigned int>(codepoint) & 0x3Fu)));
7121 error_message =
"invalid string: forbidden character after backslash";
7122 return token_type::parse_error;
7131 error_message =
"invalid string: control character U+0000 (NUL) must be escaped to \\u0000";
7132 return token_type::parse_error;
7137 error_message =
"invalid string: control character U+0001 (SOH) must be escaped to \\u0001";
7138 return token_type::parse_error;
7143 error_message =
"invalid string: control character U+0002 (STX) must be escaped to \\u0002";
7144 return token_type::parse_error;
7149 error_message =
"invalid string: control character U+0003 (ETX) must be escaped to \\u0003";
7150 return token_type::parse_error;
7155 error_message =
"invalid string: control character U+0004 (EOT) must be escaped to \\u0004";
7156 return token_type::parse_error;
7161 error_message =
"invalid string: control character U+0005 (ENQ) must be escaped to \\u0005";
7162 return token_type::parse_error;
7167 error_message =
"invalid string: control character U+0006 (ACK) must be escaped to \\u0006";
7168 return token_type::parse_error;
7173 error_message =
"invalid string: control character U+0007 (BEL) must be escaped to \\u0007";
7174 return token_type::parse_error;
7179 error_message =
"invalid string: control character U+0008 (BS) must be escaped to \\u0008 or \\b";
7180 return token_type::parse_error;
7185 error_message =
"invalid string: control character U+0009 (HT) must be escaped to \\u0009 or \\t";
7186 return token_type::parse_error;
7191 error_message =
"invalid string: control character U+000A (LF) must be escaped to \\u000A or \\n";
7192 return token_type::parse_error;
7197 error_message =
"invalid string: control character U+000B (VT) must be escaped to \\u000B";
7198 return token_type::parse_error;
7203 error_message =
"invalid string: control character U+000C (FF) must be escaped to \\u000C or \\f";
7204 return token_type::parse_error;
7209 error_message =
"invalid string: control character U+000D (CR) must be escaped to \\u000D or \\r";
7210 return token_type::parse_error;
7215 error_message =
"invalid string: control character U+000E (SO) must be escaped to \\u000E";
7216 return token_type::parse_error;
7221 error_message =
"invalid string: control character U+000F (SI) must be escaped to \\u000F";
7222 return token_type::parse_error;
7227 error_message =
"invalid string: control character U+0010 (DLE) must be escaped to \\u0010";
7228 return token_type::parse_error;
7233 error_message =
"invalid string: control character U+0011 (DC1) must be escaped to \\u0011";
7234 return token_type::parse_error;
7239 error_message =
"invalid string: control character U+0012 (DC2) must be escaped to \\u0012";
7240 return token_type::parse_error;
7245 error_message =
"invalid string: control character U+0013 (DC3) must be escaped to \\u0013";
7246 return token_type::parse_error;
7251 error_message =
"invalid string: control character U+0014 (DC4) must be escaped to \\u0014";
7252 return token_type::parse_error;
7257 error_message =
"invalid string: control character U+0015 (NAK) must be escaped to \\u0015";
7258 return token_type::parse_error;
7263 error_message =
"invalid string: control character U+0016 (SYN) must be escaped to \\u0016";
7264 return token_type::parse_error;
7269 error_message =
"invalid string: control character U+0017 (ETB) must be escaped to \\u0017";
7270 return token_type::parse_error;
7275 error_message =
"invalid string: control character U+0018 (CAN) must be escaped to \\u0018";
7276 return token_type::parse_error;
7281 error_message =
"invalid string: control character U+0019 (EM) must be escaped to \\u0019";
7282 return token_type::parse_error;
7287 error_message =
"invalid string: control character U+001A (SUB) must be escaped to \\u001A";
7288 return token_type::parse_error;
7293 error_message =
"invalid string: control character U+001B (ESC) must be escaped to \\u001B";
7294 return token_type::parse_error;
7299 error_message =
"invalid string: control character U+001C (FS) must be escaped to \\u001C";
7300 return token_type::parse_error;
7305 error_message =
"invalid string: control character U+001D (GS) must be escaped to \\u001D";
7306 return token_type::parse_error;
7311 error_message =
"invalid string: control character U+001E (RS) must be escaped to \\u001E";
7312 return token_type::parse_error;
7317 error_message =
"invalid string: control character U+001F (US) must be escaped to \\u001F";
7318 return token_type::parse_error;
7455 return token_type::parse_error;
7465 return token_type::parse_error;
7489 return token_type::parse_error;
7499 return token_type::parse_error;
7509 return token_type::parse_error;
7521 return token_type::parse_error;
7531 return token_type::parse_error;
7539 error_message =
"invalid string: ill-formed UTF-8 byte";
7540 return token_type::parse_error;
7563 case std::char_traits<char_type>::eof():
7580 case std::char_traits<char_type>::eof():
7583 error_message =
"invalid comment; missing closing '*/'";
7611 error_message =
"invalid comment; expecting '/' or '*' after '/'";
7618 static
void strtof(
float& f, const
char* str,
char** endptr) noexcept
7620 f = std::strtof(str, endptr);
7624 static
void strtof(
double& f, const
char* str,
char** endptr) noexcept
7626 f = std::strtod(str, endptr);
7630 static
void strtof(
long double& f, const
char* str,
char** endptr) noexcept
7632 f = std::strtold(str, endptr);
7675 token_type scan_number()
7682 token_type number_type = token_type::value_unsigned;
7690 goto scan_number_minus;
7696 goto scan_number_zero;
7710 goto scan_number_any1;
7720 number_type = token_type::value_integer;
7726 goto scan_number_zero;
7740 goto scan_number_any1;
7745 error_message =
"invalid number; expected digit after '-'";
7746 return token_type::parse_error;
7756 add(decimal_point_char);
7757 goto scan_number_decimal1;
7764 goto scan_number_exponent;
7768 goto scan_number_done;
7787 goto scan_number_any1;
7792 add(decimal_point_char);
7793 goto scan_number_decimal1;
7800 goto scan_number_exponent;
7804 goto scan_number_done;
7807scan_number_decimal1:
7809 number_type = token_type::value_float;
7824 goto scan_number_decimal2;
7829 error_message =
"invalid number; expected digit after '.'";
7830 return token_type::parse_error;
7834scan_number_decimal2:
7850 goto scan_number_decimal2;
7857 goto scan_number_exponent;
7861 goto scan_number_done;
7864scan_number_exponent:
7866 number_type = token_type::value_float;
7873 goto scan_number_sign;
7888 goto scan_number_any2;
7894 "invalid number; expected '+', '-', or digit after exponent";
7895 return token_type::parse_error;
7915 goto scan_number_any2;
7920 error_message =
"invalid number; expected digit after exponent sign";
7921 return token_type::parse_error;
7941 goto scan_number_any2;
7945 goto scan_number_done;
7953 char* endptr =
nullptr;
7957 if (number_type == token_type::value_unsigned)
7959 const auto x = std::strtoull(token_buffer.data(), &endptr, 10);
7962 JSON_ASSERT(endptr == token_buffer.data() + token_buffer.size());
7966 value_unsigned =
static_cast<number_unsigned_t
>(x);
7967 if (value_unsigned == x)
7969 return token_type::value_unsigned;
7973 else if (number_type == token_type::value_integer)
7975 const auto x = std::strtoll(token_buffer.data(), &endptr, 10);
7978 JSON_ASSERT(endptr == token_buffer.data() + token_buffer.size());
7982 value_integer =
static_cast<number_integer_t
>(x);
7983 if (value_integer == x)
7985 return token_type::value_integer;
7992 strtof(value_float, token_buffer.data(), &endptr);
7995 JSON_ASSERT(endptr == token_buffer.data() + token_buffer.size());
7997 return token_type::value_float;
8006 token_type scan_literal(const char_type* literal_text, const
std::
size_t length,
8007 token_type return_type)
8009 JSON_ASSERT(std::char_traits<char_type>::to_char_type(current) == literal_text[0]);
8010 for (std::size_t i = 1; i < length; ++i)
8014 error_message =
"invalid literal";
8015 return token_type::parse_error;
8026 void reset() noexcept
8028 token_buffer.clear();
8029 token_string.clear();
8030 token_string.push_back(std::char_traits<char_type>::to_char_type(current));
8045 ++position.chars_read_total;
8046 ++position.chars_read_current_line;
8055 current = ia.get_character();
8060 token_string.push_back(std::char_traits<char_type>::to_char_type(current));
8063 if (current ==
'\n')
8065 ++position.lines_read;
8066 position.chars_read_current_line = 0;
8084 --position.chars_read_total;
8087 if (position.chars_read_current_line == 0)
8089 if (position.lines_read > 0)
8091 --position.lines_read;
8096 --position.chars_read_current_line;
8102 token_string.pop_back();
8107 void add(char_int_type c)
8109 token_buffer.push_back(
static_cast<typename string_t::value_type
>(c));
8120 return value_integer;
8126 return value_unsigned;
8138 return token_buffer;
8158 for (
const auto c : token_string)
8160 if (
static_cast<unsigned char>(c) <=
'\x1F')
8163 std::array<char, 9> cs{{}};
8164 static_cast<void>((std::snprintf)(cs.data(), cs.size(),
"<U+%.4X>",
static_cast<unsigned char>(c)));
8165 result += cs.data();
8170 result.push_back(
static_cast<std::string::value_type
>(c));
8181 return error_message;
8197 return get() == 0xBB &&
get() == 0xBF;
8212 while (current ==
' ' || current ==
'\t' || current ==
'\n' || current ==
'\r');
8218 if (position.chars_read_total == 0 && !skip_bom())
8220 error_message =
"invalid BOM; must be 0xEF 0xBB 0xBF if given";
8221 return token_type::parse_error;
8228 while (ignore_comments && current ==
'/')
8230 if (!scan_comment())
8232 return token_type::parse_error;
8243 return token_type::begin_array;
8245 return token_type::end_array;
8247 return token_type::begin_object;
8249 return token_type::end_object;
8251 return token_type::name_separator;
8253 return token_type::value_separator;
8258 std::array<char_type, 4> true_literal = {{
static_cast<char_type
>(
't'),
static_cast<char_type
>(
'r'),
static_cast<char_type
>(
'u'),
static_cast<char_type
>(
'e')}};
8259 return scan_literal(true_literal.data(), true_literal.size(), token_type::literal_true);
8263 std::array<char_type, 5> false_literal = {{
static_cast<char_type
>(
'f'),
static_cast<char_type
>(
'a'),
static_cast<char_type
>(
'l'),
static_cast<char_type
>(
's'),
static_cast<char_type
>(
'e')}};
8264 return scan_literal(false_literal.data(), false_literal.size(), token_type::literal_false);
8268 std::array<char_type, 4> null_literal = {{
static_cast<char_type
>(
'n'),
static_cast<char_type
>(
'u'),
static_cast<char_type
>(
'l'),
static_cast<char_type
>(
'l')}};
8269 return scan_literal(null_literal.data(), null_literal.size(), token_type::literal_null);
8274 return scan_string();
8288 return scan_number();
8293 case std::char_traits<char_type>::eof():
8294 return token_type::end_of_input;
8298 error_message =
"invalid literal";
8299 return token_type::parse_error;
8305 InputAdapterType ia;
8308 const bool ignore_comments =
false;
8311 char_int_type current = std::char_traits<char_type>::eof();
8314 bool next_unget =
false;
8320 std::vector<char_type> token_string {};
8323 string_t token_buffer {};
8326 const char* error_message =
"";
8329 number_integer_t value_integer = 0;
8330 number_unsigned_t value_unsigned = 0;
8331 number_float_t value_float = 0;
8334 const char_int_type decimal_point_char =
'.';
8362 decltype(std::declval<T&>().boolean(std::declval<bool>()));
8364template<
typename T,
typename Integer>
8366 decltype(std::declval<T&>().number_integer(std::declval<Integer>()));
8368template<
typename T,
typename Un
signed>
8370 decltype(std::declval<T&>().number_unsigned(std::declval<Unsigned>()));
8372template<
typename T,
typename Float,
typename String>
8374 std::declval<Float>(), std::declval<const String&>()));
8376template<
typename T,
typename String>
8378 decltype(std::declval<T&>().string(std::declval<String&>()));
8380template<
typename T,
typename Binary>
8382 decltype(std::declval<T&>().binary(std::declval<Binary&>()));
8386 decltype(std::declval<T&>().start_object(std::declval<std::size_t>()));
8388template<
typename T,
typename String>
8390 decltype(std::declval<T&>().key(std::declval<String&>()));
8397 decltype(std::declval<T&>().start_array(std::declval<std::size_t>()));
8402template<
typename T,
typename Exception>
8404 std::declval<std::size_t>(), std::declval<const std::string&>(),
8405 std::declval<const Exception&>()));
8407template<
typename SAX,
typename BasicJsonType>
8412 "BasicJsonType must be of type basic_json<...>");
8414 using number_integer_t =
typename BasicJsonType::number_integer_t;
8415 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
8416 using number_float_t =
typename BasicJsonType::number_float_t;
8417 using string_t =
typename BasicJsonType::string_t;
8418 using binary_t =
typename BasicJsonType::binary_t;
8419 using exception_t =
typename BasicJsonType::exception;
8438template<
typename SAX,
typename BasicJsonType>
8443 "BasicJsonType must be of type basic_json<...>");
8445 using number_integer_t =
typename BasicJsonType::number_integer_t;
8446 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
8447 using number_float_t =
typename BasicJsonType::number_float_t;
8448 using string_t =
typename BasicJsonType::string_t;
8449 using binary_t =
typename BasicJsonType::binary_t;
8450 using exception_t =
typename BasicJsonType::exception;
8454 "Missing/invalid function: bool null()");
8456 "Missing/invalid function: bool boolean(bool)");
8458 "Missing/invalid function: bool boolean(bool)");
8461 number_integer_t>::value,
8462 "Missing/invalid function: bool number_integer(number_integer_t)");
8465 number_unsigned_t>::value,
8466 "Missing/invalid function: bool number_unsigned(number_unsigned_t)");
8468 number_float_t, string_t>::value,
8469 "Missing/invalid function: bool number_float(number_float_t, const string_t&)");
8472 "Missing/invalid function: bool string(string_t&)");
8475 "Missing/invalid function: bool binary(binary_t&)");
8477 "Missing/invalid function: bool start_object(std::size_t)");
8479 "Missing/invalid function: bool key(string_t&)");
8481 "Missing/invalid function: bool end_object()");
8483 "Missing/invalid function: bool start_array(std::size_t)");
8485 "Missing/invalid function: bool end_array()");
8488 "Missing/invalid function: bool parse_error(std::size_t, const "
8489 "std::string&, const exception&)");
8521static inline bool little_endianness(
int num = 1) noexcept
8523 return *
reinterpret_cast<char*
>(&num) == 1;
8534template<
typename BasicJsonType,
typename InputAdapterType,
typename SAX = json_sax_dom_parser<BasicJsonType>>
8537 using number_integer_t =
typename BasicJsonType::number_integer_t;
8538 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
8539 using number_float_t =
typename BasicJsonType::number_float_t;
8540 using string_t =
typename BasicJsonType::string_t;
8541 using binary_t =
typename BasicJsonType::binary_t;
8542 using json_sax_t = SAX;
8543 using char_type =
typename InputAdapterType::char_type;
8544 using char_int_type =
typename std::char_traits<char_type>::int_type;
8575 const
bool strict = true,
8579 bool result =
false;
8584 result = parse_bson_internal();
8588 result = parse_cbor_internal(
true, tag_handler);
8592 result = parse_msgpack_internal();
8597 result = parse_ubjson_internal();
8619 return sax->parse_error(chars_read, get_token_string(),
parse_error::create(110, chars_read,
8620 exception_message(input_format,
concat(
"expected end of input; last byte: 0x", get_token_string()),
"value"),
nullptr));
8636 bool parse_bson_internal()
8638 std::int32_t document_size{};
8651 return sax->end_object();
8661 bool get_bson_cstr(string_t& result)
8663 auto out = std::back_inserter(result);
8671 if (current == 0x00)
8675 *out++ =
static_cast<typename string_t::value_type
>(current);
8690 template<
typename NumberType>
8691 bool get_bson_string(
const NumberType len, string_t& result)
8695 auto last_token = get_token_string();
8700 return get_string(
input_format_t::bson, len -
static_cast<NumberType
>(1), result) && get() != std::char_traits<char_type>::eof();
8712 template<
typename NumberType>
8713 bool get_bson_binary(
const NumberType len, binary_t& result)
8717 auto last_token = get_token_string();
8723 std::uint8_t subtype{};
8725 result.set_subtype(subtype);
8740 bool parse_bson_element_internal(
const char_int_type element_type,
8741 const std::size_t element_type_parse_position)
8743 switch (element_type)
8748 return get_number<double, true>(
input_format_t::bson, number) && sax->number_float(
static_cast<number_float_t
>(number),
"");
8755 return get_number<std::int32_t, true>(
input_format_t::bson, len) && get_bson_string(len, value) && sax->string(value);
8760 return parse_bson_internal();
8765 return parse_bson_array();
8772 return get_number<std::int32_t, true>(
input_format_t::bson, len) && get_bson_binary(len, value) && sax->binary(value);
8777 return sax->boolean(get() != 0);
8787 std::int32_t
value{};
8788 return get_number<std::int32_t, true>(
input_format_t::bson, value) && sax->number_integer(value);
8793 std::int64_t
value{};
8794 return get_number<std::int64_t, true>(
input_format_t::bson, value) && sax->number_integer(value);
8799 std::array<char, 3> cr{{}};
8800 static_cast<void>((std::snprintf)(cr.data(), cr.size(),
"%.2hhX",
static_cast<unsigned char>(element_type)));
8801 std::string cr_str{cr.data()};
8802 return sax->parse_error(element_type_parse_position, cr_str,
8820 bool parse_bson_element_list(
const bool is_array)
8824 while (
auto element_type = get())
8831 const std::size_t element_type_parse_position = chars_read;
8837 if (!is_array && !sax->key(key))
8842 if (
JSON_HEDLEY_UNLIKELY(!parse_bson_element_internal(element_type, element_type_parse_position)))
8858 bool parse_bson_array()
8860 std::int32_t document_size{};
8873 return sax->end_array();
8888 bool parse_cbor_internal(
const bool get_char,
8891 switch (get_char ? get() : current)
8894 case std::char_traits<char_type>::eof():
8922 return sax->number_unsigned(
static_cast<number_unsigned_t
>(current));
8926 std::uint8_t number{};
8932 std::uint16_t number{};
8938 std::uint32_t number{};
8944 std::uint64_t number{};
8973 return sax->number_integer(
static_cast<std::int8_t
>(0x20 - 1 - current));
8977 std::uint8_t number{};
8978 return get_number(
input_format_t::cbor, number) && sax->number_integer(
static_cast<number_integer_t
>(-1) - number);
8983 std::uint16_t number{};
8984 return get_number(
input_format_t::cbor, number) && sax->number_integer(
static_cast<number_integer_t
>(-1) - number);
8989 std::uint32_t number{};
8990 return get_number(
input_format_t::cbor, number) && sax->number_integer(
static_cast<number_integer_t
>(-1) - number);
8995 std::uint64_t number{};
8996 return get_number(
input_format_t::cbor, number) && sax->number_integer(
static_cast<number_integer_t
>(-1)
8997 -
static_cast<number_integer_t
>(number));
9032 return get_cbor_binary(b) && sax->binary(b);
9067 return get_cbor_string(s) && sax->string(s);
9095 return get_cbor_array(
static_cast<std::size_t
>(
static_cast<unsigned int>(current) & 0x1Fu), tag_handler);
9100 return get_number(
input_format_t::cbor, len) && get_cbor_array(
static_cast<std::size_t
>(len), tag_handler);
9105 std::uint16_t len{};
9106 return get_number(
input_format_t::cbor, len) && get_cbor_array(
static_cast<std::size_t
>(len), tag_handler);
9111 std::uint32_t len{};
9112 return get_number(
input_format_t::cbor, len) && get_cbor_array(
static_cast<std::size_t
>(len), tag_handler);
9117 std::uint64_t len{};
9118 return get_number(
input_format_t::cbor, len) && get_cbor_array(detail::conditional_static_cast<std::size_t>(len), tag_handler);
9122 return get_cbor_array(
static_cast<std::size_t
>(-1), tag_handler);
9149 return get_cbor_object(
static_cast<std::size_t
>(
static_cast<unsigned int>(current) & 0x1Fu), tag_handler);
9154 return get_number(
input_format_t::cbor, len) && get_cbor_object(
static_cast<std::size_t
>(len), tag_handler);
9159 std::uint16_t len{};
9160 return get_number(
input_format_t::cbor, len) && get_cbor_object(
static_cast<std::size_t
>(len), tag_handler);
9165 std::uint32_t len{};
9166 return get_number(
input_format_t::cbor, len) && get_cbor_object(
static_cast<std::size_t
>(len), tag_handler);
9171 std::uint64_t len{};
9172 return get_number(
input_format_t::cbor, len) && get_cbor_object(detail::conditional_static_cast<std::size_t>(len), tag_handler);
9176 return get_cbor_object(
static_cast<std::size_t
>(-1), tag_handler);
9198 switch (tag_handler)
9202 auto last_token = get_token_string();
9214 std::uint8_t subtype_to_ignore{};
9220 std::uint16_t subtype_to_ignore{};
9226 std::uint32_t subtype_to_ignore{};
9232 std::uint64_t subtype_to_ignore{};
9239 return parse_cbor_internal(
true, tag_handler);
9250 std::uint8_t subtype{};
9252 b.set_subtype(detail::conditional_static_cast<typename binary_t::subtype_type>(subtype));
9257 std::uint16_t subtype{};
9259 b.set_subtype(detail::conditional_static_cast<typename binary_t::subtype_type>(subtype));
9264 std::uint32_t subtype{};
9266 b.set_subtype(detail::conditional_static_cast<typename binary_t::subtype_type>(subtype));
9271 std::uint64_t subtype{};
9273 b.set_subtype(detail::conditional_static_cast<typename binary_t::subtype_type>(subtype));
9277 return parse_cbor_internal(
true, tag_handler);
9280 return get_cbor_binary(b) && sax->binary(b);
9290 return sax->boolean(
false);
9293 return sax->boolean(
true);
9300 const auto byte1_raw = get();
9305 const auto byte2_raw = get();
9311 const auto byte1 =
static_cast<unsigned char>(byte1_raw);
9312 const auto byte2 =
static_cast<unsigned char>(byte2_raw);
9322 const auto half =
static_cast<unsigned int>((byte1 << 8u) + byte2);
9323 const double val = [&half]
9325 const int exp = (half >> 10u) & 0x1Fu;
9326 const unsigned int mant = half & 0x3FFu;
9332 return std::ldexp(mant, -24);
9335 ? std::numeric_limits<double>::infinity()
9336 :
std::numeric_limits<double>::quiet_NaN();
9338 return std::ldexp(mant + 1024, exp - 25);
9341 return sax->number_float((half & 0x8000u) != 0
9342 ?
static_cast<number_float_t
>(-val)
9343 :
static_cast<number_float_t
>(val),
"");
9349 return get_number(
input_format_t::cbor, number) && sax->number_float(
static_cast<number_float_t
>(number),
"");
9355 return get_number(
input_format_t::cbor, number) && sax->number_float(
static_cast<number_float_t
>(number),
"");
9360 auto last_token = get_token_string();
9378 bool get_cbor_string(string_t& result)
9424 std::uint16_t len{};
9430 std::uint32_t len{};
9436 std::uint64_t len{};
9442 while (get() != 0xFF)
9445 if (!get_cbor_string(chunk))
9449 result.append(chunk);
9456 auto last_token = get_token_string();
9458 exception_message(
input_format_t::cbor,
concat(
"expected length specification (0x60-0x7B) or indefinite string type (0x7F); last byte: 0x", last_token),
"string"),
nullptr));
9474 bool get_cbor_binary(binary_t& result)
9521 std::uint16_t len{};
9528 std::uint32_t len{};
9535 std::uint64_t len{};
9542 while (get() != 0xFF)
9545 if (!get_cbor_binary(chunk))
9549 result.insert(result.end(), chunk.begin(), chunk.end());
9556 auto last_token = get_token_string();
9558 exception_message(
input_format_t::cbor,
concat(
"expected length specification (0x40-0x5B) or indefinite binary array type (0x5F); last byte: 0x", last_token),
"binary"),
nullptr));
9569 bool get_cbor_array(
const std::size_t len,
9577 if (len !=
static_cast<std::size_t
>(-1))
9579 for (std::size_t i = 0; i < len; ++i)
9589 while (get() != 0xFF)
9598 return sax->end_array();
9607 bool get_cbor_object(
const std::size_t len,
9618 if (len !=
static_cast<std::size_t
>(-1))
9620 for (std::size_t i = 0; i < len; ++i)
9637 while (get() != 0xFF)
9653 return sax->end_object();
9663 bool parse_msgpack_internal()
9668 case std::char_traits<char_type>::eof():
9800 return sax->number_unsigned(
static_cast<number_unsigned_t
>(current));
9819 return get_msgpack_object(
static_cast<std::size_t
>(
static_cast<unsigned int>(current) & 0x0Fu));
9838 return get_msgpack_array(
static_cast<std::size_t
>(
static_cast<unsigned int>(current) & 0x0Fu));
9878 return get_msgpack_string(s) && sax->string(s);
9885 return sax->boolean(
false);
9888 return sax->boolean(
true);
9903 return get_msgpack_binary(b) && sax->binary(b);
9909 return get_number(
input_format_t::msgpack, number) && sax->number_float(
static_cast<number_float_t
>(number),
"");
9915 return get_number(
input_format_t::msgpack, number) && sax->number_float(
static_cast<number_float_t
>(number),
"");
9920 std::uint8_t number{};
9926 std::uint16_t number{};
9932 std::uint32_t number{};
9938 std::uint64_t number{};
9944 std::int8_t number{};
9950 std::int16_t number{};
9956 std::int32_t number{};
9962 std::int64_t number{};
9968 std::uint16_t len{};
9974 std::uint32_t len{};
9980 std::uint16_t len{};
9986 std::uint32_t len{};
10023 return sax->number_integer(
static_cast<std::int8_t
>(current));
10027 auto last_token = get_token_string();
10044 bool get_msgpack_string(string_t& result)
10092 std::uint8_t len{};
10098 std::uint16_t len{};
10104 std::uint32_t len{};
10110 auto last_token = get_token_string();
10112 exception_message(
input_format_t::msgpack,
concat(
"expected length specification (0xA0-0xBF, 0xD9-0xDB); last byte: 0x", last_token),
"string"),
nullptr));
10127 bool get_msgpack_binary(binary_t& result)
10130 auto assign_and_return_true = [&result](std::int8_t subtype)
10132 result.set_subtype(
static_cast<std::uint8_t
>(subtype));
10140 std::uint8_t len{};
10147 std::uint16_t len{};
10154 std::uint32_t len{};
10161 std::uint8_t len{};
10162 std::int8_t subtype{};
10166 assign_and_return_true(subtype);
10171 std::uint16_t len{};
10172 std::int8_t subtype{};
10176 assign_and_return_true(subtype);
10181 std::uint32_t len{};
10182 std::int8_t subtype{};
10186 assign_and_return_true(subtype);
10191 std::int8_t subtype{};
10194 assign_and_return_true(subtype);
10199 std::int8_t subtype{};
10202 assign_and_return_true(subtype);
10207 std::int8_t subtype{};
10210 assign_and_return_true(subtype);
10215 std::int8_t subtype{};
10218 assign_and_return_true(subtype);
10223 std::int8_t subtype{};
10226 assign_and_return_true(subtype);
10238 bool get_msgpack_array(
const std::size_t len)
10245 for (std::size_t i = 0; i < len; ++i)
10253 return sax->end_array();
10260 bool get_msgpack_object(
const std::size_t len)
10268 for (std::size_t i = 0; i < len; ++i)
10283 return sax->end_object();
10297 bool parse_ubjson_internal(
const bool get_char =
true)
10299 return get_ubjson_value(get_char ? get_ignore_noop() : current);
10316 bool get_ubjson_string(string_t& result,
const bool get_char =
true)
10332 std::uint8_t len{};
10333 return get_number(input_format, len) && get_string(input_format, len, result);
10339 return get_number(input_format, len) && get_string(input_format, len, result);
10344 std::int16_t len{};
10345 return get_number(input_format, len) && get_string(input_format, len, result);
10350 std::int32_t len{};
10351 return get_number(input_format, len) && get_string(input_format, len, result);
10356 std::int64_t len{};
10357 return get_number(input_format, len) && get_string(input_format, len, result);
10366 std::uint16_t len{};
10367 return get_number(input_format, len) && get_string(input_format, len, result);
10376 std::uint32_t len{};
10377 return get_number(input_format, len) && get_string(input_format, len, result);
10386 std::uint64_t len{};
10387 return get_number(input_format, len) && get_string(input_format, len, result);
10393 auto last_token = get_token_string();
10394 std::string message;
10398 message =
"expected length type specification (U, i, I, l, L); last byte: 0x" + last_token;
10402 message =
"expected length type specification (U, i, u, I, m, l, M, L); last byte: 0x" + last_token;
10404 return sax->parse_error(chars_read, last_token,
parse_error::create(113, chars_read, exception_message(input_format, message,
"string"),
nullptr));
10411 bool get_ubjson_ndarray_size(std::vector<size_t>& dim)
10413 std::pair<std::size_t, char_int_type> size_and_type;
10415 bool is_ndarray =
false;
10422 if (size_and_type.first != string_t::npos)
10424 if (size_and_type.second != 0)
10426 if (size_and_type.second !=
'N')
10428 for (std::size_t i = 0; i < size_and_type.first; ++i)
10434 dim.push_back(dimlen);
10440 for (std::size_t i = 0; i < size_and_type.first; ++i)
10446 dim.push_back(dimlen);
10452 while (current !=
']')
10458 dim.push_back(dimlen);
10469 bool get_ubjson_size_value(std::size_t& result,
bool& is_ndarray, char_int_type prefix = 0)
10471 is_ndarray =
false;
10474 prefix = get_ignore_noop();
10481 std::uint8_t number{};
10486 result =
static_cast<std::size_t
>(number);
10492 std::int8_t number{};
10497 result =
static_cast<std::size_t
>(number);
10503 std::int16_t number{};
10508 result =
static_cast<std::size_t
>(number);
10514 std::int32_t number{};
10519 result =
static_cast<std::size_t
>(number);
10525 std::int64_t number{};
10530 result =
static_cast<std::size_t
>(number);
10540 std::uint16_t number{};
10545 result =
static_cast<std::size_t
>(number);
10555 std::uint32_t number{};
10560 result =
static_cast<std::size_t
>(number);
10570 std::uint64_t number{};
10575 result = detail::conditional_static_cast<std::size_t>(number);
10585 std::vector<size_t> dim;
10590 if (dim.size() == 1 || (dim.size() == 2 && dim.at(0) == 1))
10592 result = dim.at(dim.size() - 1);
10597 string_t
key =
"_ArraySize_";
10598 if (
JSON_HEDLEY_UNLIKELY(!sax->start_object(3) || !sax->key(key) || !sax->start_array(dim.size())))
10612 return sax->end_array();
10621 auto last_token = get_token_string();
10622 std::string message;
10626 message =
"expected length type specification (U, i, I, l, L) after '#'; last byte: 0x" + last_token;
10630 message =
"expected length type specification (U, i, u, I, m, l, M, L) after '#'; last byte: 0x" + last_token;
10632 return sax->parse_error(chars_read, last_token,
parse_error::create(113, chars_read, exception_message(input_format, message,
"size"),
nullptr));
10645 bool get_ubjson_size_type(std::pair<std::size_t, char_int_type>& result)
10647 bool is_ndarray =
false;
10648 result.first = string_t::npos;
10653 if (current ==
'$')
10655 std::vector<char_int_type> bjdx = {
'[',
'{',
'S',
'H',
'T',
'F',
'N',
'Z'};
10657 result.second = get();
10660 auto last_token = get_token_string();
10662 exception_message(input_format,
concat(
"marker 0x", last_token,
" is not a permitted optimized array type"),
"type"),
nullptr));
10677 auto last_token = get_token_string();
10679 exception_message(input_format,
concat(
"expected '#' after type information; last byte: 0x", last_token),
"size"),
nullptr));
10682 bool is_error = get_ubjson_size_value(result.first, is_ndarray);
10685 result.second |= (1 << 8);
10690 if (current ==
'#')
10692 bool is_error = get_ubjson_size_value(result.first, is_ndarray);
10695 result.second |= (1 << 8);
10707 bool get_ubjson_value(
const char_int_type prefix)
10711 case std::char_traits<char_type>::eof():
10712 return unexpect_eof(input_format,
"value");
10715 return sax->boolean(
true);
10717 return sax->boolean(
false);
10720 return sax->null();
10724 std::uint8_t number{};
10725 return get_number(input_format, number) && sax->number_unsigned(number);
10730 std::int8_t number{};
10731 return get_number(input_format, number) && sax->number_integer(number);
10736 std::int16_t number{};
10737 return get_number(input_format, number) && sax->number_integer(number);
10742 std::int32_t number{};
10743 return get_number(input_format, number) && sax->number_integer(number);
10748 std::int64_t number{};
10749 return get_number(input_format, number) && sax->number_integer(number);
10758 std::uint16_t number{};
10759 return get_number(input_format, number) && sax->number_unsigned(number);
10768 std::uint32_t number{};
10769 return get_number(input_format, number) && sax->number_unsigned(number);
10778 std::uint64_t number{};
10779 return get_number(input_format, number) && sax->number_unsigned(number);
10788 const auto byte1_raw = get();
10793 const auto byte2_raw = get();
10799 const auto byte1 =
static_cast<unsigned char>(byte1_raw);
10800 const auto byte2 =
static_cast<unsigned char>(byte2_raw);
10810 const auto half =
static_cast<unsigned int>((byte2 << 8u) + byte1);
10811 const double val = [&half]
10813 const int exp = (half >> 10u) & 0x1Fu;
10814 const unsigned int mant = half & 0x3FFu;
10820 return std::ldexp(mant, -24);
10823 ? std::numeric_limits<double>::infinity()
10824 :
std::numeric_limits<double>::quiet_NaN();
10826 return std::ldexp(mant + 1024, exp - 25);
10829 return sax->number_float((half & 0x8000u) != 0
10830 ?
static_cast<number_float_t
>(-val)
10831 :
static_cast<number_float_t
>(val),
"");
10837 return get_number(input_format, number) && sax->number_float(
static_cast<number_float_t
>(number),
"");
10843 return get_number(input_format, number) && sax->number_float(
static_cast<number_float_t
>(number),
"");
10848 return get_ubjson_high_precision_number();
10860 auto last_token = get_token_string();
10862 exception_message(input_format,
concat(
"byte after 'C' must be in range 0x00..0x7F; last byte: 0x", last_token),
"char"),
nullptr));
10864 string_t s(1,
static_cast<typename string_t::value_type
>(current));
10865 return sax->string(s);
10871 return get_ubjson_string(s) && sax->string(s);
10875 return get_ubjson_array();
10878 return get_ubjson_object();
10883 auto last_token = get_token_string();
10884 return sax->parse_error(chars_read, last_token,
parse_error::create(112, chars_read, exception_message(input_format,
"invalid byte: 0x" + last_token,
"value"),
nullptr));
10890 bool get_ubjson_array()
10892 std::pair<std::size_t, char_int_type> size_and_type;
10901 if (input_format ==
input_format_t::bjdata && size_and_type.first != string_t::npos && (size_and_type.second & (1 << 8)) != 0)
10903 std::map<char_int_type, string_t> bjdtype = {{
'U',
"uint8"}, {
'i',
"int8"}, {
'u',
"uint16"}, {
'I',
"int16"},
10904 {
'm',
"uint32"}, {
'l',
"int32"}, {
'M',
"uint64"}, {
'L',
"int64"}, {
'd',
"single"}, {
'D',
"double"}, {
'C',
"char"}
10907 size_and_type.second &= ~(
static_cast<char_int_type
>(1) << 8);
10909 string_t
key =
"_ArrayType_";
10912 auto last_token = get_token_string();
10914 exception_message(input_format,
"invalid byte: 0x" + last_token,
"type"),
nullptr));
10922 if (size_and_type.second ==
'C')
10924 size_and_type.second =
'U';
10927 key =
"_ArrayData_";
10933 for (std::size_t i = 0; i < size_and_type.first; ++i)
10941 return (sax->end_array() && sax->end_object());
10944 if (size_and_type.first != string_t::npos)
10951 if (size_and_type.second != 0)
10953 if (size_and_type.second !=
'N')
10955 for (std::size_t i = 0; i < size_and_type.first; ++i)
10966 for (std::size_t i = 0; i < size_and_type.first; ++i)
10982 while (current !=
']')
10992 return sax->end_array();
10998 bool get_ubjson_object()
11000 std::pair<std::size_t, char_int_type> size_and_type;
11007 if (input_format ==
input_format_t::bjdata && size_and_type.first != string_t::npos && (size_and_type.second & (1 << 8)) != 0)
11009 auto last_token = get_token_string();
11011 exception_message(input_format,
"BJData object does not support ND-array size in optimized format",
"object"),
nullptr));
11015 if (size_and_type.first != string_t::npos)
11022 if (size_and_type.second != 0)
11024 for (std::size_t i = 0; i < size_and_type.first; ++i)
11039 for (std::size_t i = 0; i < size_and_type.first; ++i)
11060 while (current !=
'}')
11075 return sax->end_object();
11081 bool get_ubjson_high_precision_number()
11084 std::size_t size{};
11085 bool is_ndarray =
false;
11086 auto res = get_ubjson_size_value(size, is_ndarray);
11093 std::vector<char> number_vector;
11094 for (std::size_t i = 0; i < size; ++i)
11101 number_vector.push_back(
static_cast<char>(current));
11106 auto number_lexer = detail::lexer<BasicJsonType, ia_type>(
detail::input_adapter(number_vector),
false);
11107 const auto result_number = number_lexer.scan();
11108 const auto number_string = number_lexer.get_token_string();
11109 const auto result_remainder = number_lexer.scan();
11116 exception_message(input_format,
concat(
"invalid number text: ", number_lexer.get_token_string()),
"high-precision number"),
nullptr));
11119 switch (result_number)
11121 case token_type::value_integer:
11122 return sax->number_integer(number_lexer.get_number_integer());
11123 case token_type::value_unsigned:
11124 return sax->number_unsigned(number_lexer.get_number_unsigned());
11125 case token_type::value_float:
11126 return sax->number_float(number_lexer.get_number_float(), std::move(number_string));
11127 case token_type::uninitialized:
11128 case token_type::literal_true:
11129 case token_type::literal_false:
11130 case token_type::literal_null:
11131 case token_type::value_string:
11132 case token_type::begin_array:
11133 case token_type::begin_object:
11134 case token_type::end_array:
11135 case token_type::end_object:
11136 case token_type::name_separator:
11137 case token_type::value_separator:
11138 case token_type::parse_error:
11139 case token_type::end_of_input:
11140 case token_type::literal_or_value:
11143 exception_message(input_format,
concat(
"invalid number text: ", number_lexer.get_token_string()),
"high-precision number"),
nullptr));
11160 char_int_type get()
11163 return current = ia.get_character();
11169 char_int_type get_ignore_noop()
11175 while (current ==
'N');
11195 template<
typename NumberType,
bool InputIsLittleEndian = false>
11196 bool get_number(
const input_format_t format, NumberType& result)
11199 std::array<std::uint8_t,
sizeof(NumberType)> vec{};
11200 for (std::size_t i = 0; i <
sizeof(NumberType); ++i)
11211 vec[
sizeof(NumberType) - i - 1] =
static_cast<std::uint8_t
>(current);
11215 vec[i] =
static_cast<std::uint8_t
>(current);
11220 std::memcpy(&result, vec.data(),
sizeof(NumberType));
11238 template<
typename NumberType>
11240 const NumberType len,
11243 bool success =
true;
11244 for (NumberType i = 0; i < len; i++)
11252 result.push_back(
static_cast<typename string_t::value_type
>(current));
11271 template<
typename NumberType>
11273 const NumberType len,
11276 bool success =
true;
11277 for (NumberType i = 0; i < len; i++)
11285 result.push_back(
static_cast<std::uint8_t
>(current));
11296 bool unexpect_eof(const
input_format_t format, const
char* context)
const
11300 return sax->parse_error(chars_read,
"<end of file>",
11301 parse_error::create(110, chars_read, exception_message(format,
"unexpected end of input", context),
nullptr));
11309 std::string get_token_string()
const
11311 std::array<char, 3> cr{{}};
11312 static_cast<void>((std::snprintf)(cr.data(), cr.size(),
"%.2hhX",
static_cast<unsigned char>(current)));
11313 return std::string{cr.data()};
11323 const std::string& detail,
11324 const std::string& context)
const
11326 std::string error_msg =
"syntax error while parsing ";
11331 error_msg +=
"CBOR";
11335 error_msg +=
"MessagePack";
11339 error_msg +=
"UBJSON";
11343 error_msg +=
"BSON";
11347 error_msg +=
"BJData";
11355 return concat(error_msg,
' ', context,
": ", detail);
11360 InputAdapterType ia;
11363 char_int_type current = std::char_traits<char_type>::eof();
11366 std::size_t chars_read = 0;
11369 const bool is_little_endian = little_endianness();
11375 json_sax_t* sax =
nullptr;
11389#include <functional>
11435template<
typename BasicJsonType>
11437 std::function<bool(
int ,
parse_event_t , BasicJsonType& )>;
11444template<
typename BasicJsonType,
typename InputAdapterType>
11447 using number_integer_t =
typename BasicJsonType::number_integer_t;
11448 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
11449 using number_float_t =
typename BasicJsonType::number_float_t;
11450 using string_t =
typename BasicJsonType::string_t;
11458 const bool allow_exceptions_ =
true,
11459 const bool skip_comments =
false)
11461 , m_lexer(
std::move(adapter), skip_comments)
11462 , allow_exceptions(allow_exceptions_)
11478 void parse(
const bool strict, BasicJsonType& result)
11483 sax_parse_internal(&sdp);
11486 if (
strict && (get_token() != token_type::end_of_input))
11491 exception_message(token_type::end_of_input,
"value"),
nullptr));
11503 if (result.is_discarded())
11511 sax_parse_internal(&sdp);
11514 if (
strict && (get_token() != token_type::end_of_input))
11529 result.assert_invariant();
11544 template<
typename SAX>
11549 const bool result = sax_parse_internal(sax);
11552 if (result &&
strict && (get_token() != token_type::end_of_input))
11563 template<
typename SAX>
11565 bool sax_parse_internal(SAX* sax)
11569 std::vector<bool> states;
11571 bool skip_to_state_evaluation =
false;
11575 if (!skip_to_state_evaluation)
11578 switch (last_token)
11580 case token_type::begin_object:
11588 if (get_token() == token_type::end_object)
11618 states.push_back(
false);
11625 case token_type::begin_array:
11633 if (get_token() == token_type::end_array)
11643 states.push_back(
true);
11649 case token_type::value_float:
11668 case token_type::literal_false:
11677 case token_type::literal_null:
11686 case token_type::literal_true:
11695 case token_type::value_integer:
11704 case token_type::value_string:
11713 case token_type::value_unsigned:
11722 case token_type::parse_error:
11730 case token_type::uninitialized:
11731 case token_type::end_array:
11732 case token_type::end_object:
11733 case token_type::name_separator:
11734 case token_type::value_separator:
11735 case token_type::end_of_input:
11736 case token_type::literal_or_value:
11747 skip_to_state_evaluation =
false;
11751 if (states.empty())
11760 if (get_token() == token_type::value_separator)
11781 skip_to_state_evaluation =
true;
11793 if (get_token() == token_type::value_separator)
11835 skip_to_state_evaluation =
true;
11846 token_type get_token()
11848 return last_token = m_lexer.
scan();
11851 std::string exception_message(
const token_type expected,
const std::string& context)
11853 std::string error_msg =
"syntax error ";
11855 if (!context.empty())
11857 error_msg +=
concat(
"while parsing ", context,
' ');
11862 if (last_token == token_type::parse_error)
11872 if (expected != token_type::uninitialized)
11882 const parser_callback_t<BasicJsonType> callback =
nullptr;
11884 token_type last_token = token_type::uninitialized;
11888 const bool allow_exceptions =
true;
11922 using difference_type = std::ptrdiff_t;
11923 static constexpr difference_type begin_value = 0;
11924 static constexpr difference_type end_value = begin_value + 1;
11928 difference_type m_it = (std::numeric_limits<std::ptrdiff_t>::min)();
11939 m_it = begin_value;
11951 return m_it == begin_value;
11957 return m_it == end_value;
11962 return lhs.m_it == rhs.m_it;
11967 return lhs.m_it < rhs.m_it;
11972 auto result = *
this;
11979 return lhs.m_it - rhs.m_it;
11990 auto result = *
this;
12003 auto result = *
this;
12050#include <type_traits>
12072template<
typename IteratorType>
class iteration_proxy;
12073template<
typename IteratorType>
class iteration_proxy_value;
12091template<
typename BasicJsonType>
12098 friend BasicJsonType;
12102 using object_t =
typename BasicJsonType::object_t;
12103 using array_t =
typename BasicJsonType::array_t;
12106 "iter_impl only accepts (const) basic_json");
12122 using pointer =
typename std::conditional<std::is_const<BasicJsonType>::value,
12123 typename BasicJsonType::const_pointer,
12124 typename BasicJsonType::pointer>::type;
12127 typename std::conditional<std::is_const<BasicJsonType>::value,
12128 typename BasicJsonType::const_reference,
12129 typename BasicJsonType::reference>::type;
12146 switch (m_object->m_type)
12193 : m_object(other.m_object),
m_it(other.m_it)
12204 if (&other !=
this)
12206 m_object = other.m_object;
12218 : m_object(other.m_object),
m_it(other.m_it)
12229 m_object = other.m_object;
12239 void set_begin() noexcept
12243 switch (m_object->m_type)
12287 switch (m_object->m_type)
12326 switch (m_object->m_type)
12370 switch (m_object->m_type)
12410 auto result = *
this;
12423 switch (m_object->m_type)
12461 auto result = *
this;
12474 switch (m_object->m_type)
12510 template <
typename IterImpl, detail::enable_if_t < (std::is_same<IterImpl, iter_impl>::value || std::is_same<IterImpl, other_iter_impl>::value), std::
nullptr_t > =
nullptr >
12521 switch (m_object->m_type)
12546 template <
typename IterImpl, detail::enable_if_t < (std::is_same<IterImpl, iter_impl>::value || std::is_same<IterImpl, other_iter_impl>::value), std::
nullptr_t > =
nullptr >
12566 switch (m_object->m_type)
12593 return !other.operator < (*this);
12622 switch (m_object->m_type)
12666 auto result = *
this;
12688 auto result = *
this;
12701 switch (m_object->m_type)
12730 switch (m_object->m_type)
12764 const typename object_t::key_type&
key()
const
12829template<
typename Base>
12903 auto it = --this->base();
12910 auto it = --this->base();
12911 return it.operator * ();
12922#include <algorithm>
12948template<
typename RefStringType>
12958 template<
typename T>
12959 struct string_t_helper
12967 using type = StringType;
12972 using string_t =
typename string_t_helper<RefStringType>::type;
12977 : reference_tokens(split(s))
12984 return std::accumulate(reference_tokens.begin(), reference_tokens.end(),
12988 return detail::concat(a,
'/', detail::escape(b));
13003 reference_tokens.insert(reference_tokens.end(),
13004 ptr.reference_tokens.begin(),
13005 ptr.reference_tokens.end());
13069 reference_tokens.pop_back();
13081 return reference_tokens.back();
13088 reference_tokens.push_back(token);
13095 reference_tokens.push_back(std::move(token));
13102 return reference_tokens.empty();
13116 template<
typename BasicJsonType>
13117 static typename BasicJsonType::size_type array_index(
const string_t& s)
13119 using size_type =
typename BasicJsonType::size_type;
13133 const char* p = s.c_str();
13134 char* p_end =
nullptr;
13136 unsigned long long res = std::strtoull(p, &p_end, 10);
13146 if (res >=
static_cast<unsigned long long>((std::numeric_limits<size_type>::max)()))
13151 return static_cast<size_type
>(res);
13163 result.reference_tokens = {reference_tokens[0]};
13176 template<
typename BasicJsonType>
13177 BasicJsonType& get_and_create(BasicJsonType& j)
const
13183 for (
const auto& reference_token : reference_tokens)
13185 switch (result->type())
13189 if (reference_token ==
"0")
13192 result = &result->operator[](0);
13197 result = &result->operator[](reference_token);
13205 result = &result->operator[](reference_token);
13212 result = &result->operator[](array_index<BasicJsonType>(reference_token));
13256 template<
typename BasicJsonType>
13257 BasicJsonType& get_unchecked(BasicJsonType* ptr)
const
13259 for (
const auto& reference_token : reference_tokens)
13262 if (ptr->is_null())
13266 std::all_of(reference_token.begin(), reference_token.end(),
13267 [](
const unsigned char x)
13269 return std::isdigit(x);
13273 *ptr = (nums || reference_token ==
"-")
13278 switch (ptr->type())
13283 ptr = &ptr->operator[](reference_token);
13289 if (reference_token ==
"-")
13292 ptr = &ptr->operator[](ptr->m_value.array->size());
13297 ptr = &ptr->operator[](array_index<BasicJsonType>(reference_token));
13324 template<
typename BasicJsonType>
13325 BasicJsonType& get_checked(BasicJsonType* ptr)
const
13327 for (
const auto& reference_token : reference_tokens)
13329 switch (ptr->type())
13334 ptr = &ptr->at(reference_token);
13344 "array index '-' (",
std::to_string(ptr->m_value.array->size()),
13345 ") is out of range"), ptr));
13349 ptr = &ptr->at(array_index<BasicJsonType>(reference_token));
13382 template<
typename BasicJsonType>
13383 const BasicJsonType& get_unchecked(
const BasicJsonType* ptr)
const
13385 for (
const auto& reference_token : reference_tokens)
13387 switch (ptr->type())
13392 ptr = &ptr->operator[](reference_token);
13405 ptr = &ptr->operator[](array_index<BasicJsonType>(reference_token));
13431 template<
typename BasicJsonType>
13432 const BasicJsonType& get_checked(
const BasicJsonType* ptr)
const
13434 for (
const auto& reference_token : reference_tokens)
13436 switch (ptr->type())
13441 ptr = &ptr->at(reference_token);
13451 "array index '-' (",
std::to_string(ptr->m_value.array->size()),
13452 ") is out of range"), ptr));
13456 ptr = &ptr->at(array_index<BasicJsonType>(reference_token));
13480 template<
typename BasicJsonType>
13481 bool contains(
const BasicJsonType* ptr)
const
13483 for (
const auto& reference_token : reference_tokens)
13485 switch (ptr->type())
13489 if (!ptr->contains(reference_token))
13495 ptr = &ptr->operator[](reference_token);
13506 if (
JSON_HEDLEY_UNLIKELY(reference_token.size() == 1 && !(
"0" <= reference_token && reference_token <=
"9")))
13518 for (std::size_t i = 1; i < reference_token.size(); i++)
13528 const auto idx = array_index<BasicJsonType>(reference_token);
13529 if (idx >= ptr->size())
13535 ptr = &ptr->operator[](idx);
13569 static std::vector<string_t> split(
const string_t& reference_string)
13571 std::vector<string_t> result;
13574 if (reference_string.empty())
13590 std::size_t slash = reference_string.find_first_of(
'/', 1),
13597 start = (slash == string_t::npos) ? 0 : slash + 1,
13599 slash = reference_string.find_first_of(
'/', start))
13603 auto reference_token = reference_string.substr(start, slash - start);
13606 for (std::size_t pos = reference_token.find_first_of(
'~');
13607 pos != string_t::npos;
13608 pos = reference_token.find_first_of(
'~', pos + 1))
13614 (reference_token[pos + 1] !=
'0' &&
13615 reference_token[pos + 1] !=
'1')))
13622 detail::unescape(reference_token);
13623 result.push_back(reference_token);
13637 template<
typename BasicJsonType>
13638 static void flatten(
const string_t& reference_string,
13639 const BasicJsonType& value,
13640 BasicJsonType& result)
13642 switch (
value.type())
13646 if (
value.m_value.array->empty())
13649 result[reference_string] =
nullptr;
13654 for (std::size_t i = 0; i <
value.m_value.array->size(); ++i)
13657 value.m_value.array->operator[](i), result);
13665 if (
value.m_value.object->empty())
13668 result[reference_string] =
nullptr;
13673 for (
const auto& element : *
value.m_value.object)
13692 result[reference_string] =
value;
13708 template<
typename BasicJsonType>
13709 static BasicJsonType
13710 unflatten(
const BasicJsonType& value)
13717 BasicJsonType result;
13720 for (
const auto& element : *
value.m_value.object)
13731 json_pointer(element.first).get_and_create(result) = element.second;
13738 json_pointer<string_t> convert() const&
13740 json_pointer<string_t> result;
13741 result.reference_tokens = reference_tokens;
13745 json_pointer<string_t> convert()&&
13747 json_pointer<string_t> result;
13748 result.reference_tokens = std::move(reference_tokens);
13763 template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
13765 friend bool operator==(json_pointer<RefStringTypeLhs>
const& lhs,
13766 json_pointer<RefStringTypeRhs>
const& rhs)
noexcept;
13779 template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
13781 friend bool operator!=(json_pointer<RefStringTypeLhs>
const& lhs,
13782 json_pointer<RefStringTypeRhs>
const& rhs)
noexcept;
13785 std::vector<string_t> reference_tokens;
13789template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
13793 return lhs.reference_tokens == rhs.reference_tokens;
13796template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
13800 return !(lhs == rhs);
13807#include <initializer_list>
13817template<
typename BasicJsonType>
13828 : value_ref(&
value)
13832 : owned_value(init)
13839 : owned_value(
std::forward<Args>(args)...)
13851 if (value_ref ==
nullptr)
13853 return std::move(owned_value);
13860 return value_ref ? *value_ref : owned_value;
13888#include <algorithm>
13906#include <algorithm>
13940template<typename CharType>
13944template<typename CharType, typename AllocatorType =
std::allocator<CharType>>
13958 void write_characters(const CharType* s,
std::
size_t length)
override
13960 std::copy(s, s + length, std::back_inserter(v));
13964 std::vector<CharType, AllocatorType>& v;
13969template<
typename CharType>
13983 void write_characters(const CharType* s,
std::
size_t length)
override
13985 stream.write(s,
static_cast<std::streamsize
>(length));
13989 std::basic_ostream<CharType>& stream;
13994template<
typename CharType,
typename StringType = std::basic_
string<CharType>>
14008 void write_characters(const CharType* s,
std::
size_t length)
override
14010 str.append(s, length);
14017template<
typename CharType,
typename StringType = std::basic_
string<CharType>>
14021 template<
typename AllocatorType = std::allocator<CharType>>
14058template<
typename BasicJsonType,
typename CharType>
14061 using string_t =
typename BasicJsonType::string_t;
14062 using binary_t =
typename BasicJsonType::binary_t;
14063 using number_float_t =
typename BasicJsonType::number_float_t;
14084 case value_t::object:
14086 write_bson_object(*j.m_value.object);
14090 case value_t::null:
14091 case value_t::array:
14092 case value_t::string:
14093 case value_t::boolean:
14094 case value_t::number_integer:
14095 case value_t::number_unsigned:
14096 case value_t::number_float:
14097 case value_t::binary:
14098 case value_t::discarded:
14101 JSON_THROW(type_error::create(317,
concat(
"to serialize to BSON, top-level type must be object, but is ", j.type_name()), &j));
14113 case value_t::null:
14115 oa->write_character(to_char_type(0xF6));
14119 case value_t::boolean:
14121 oa->write_character(j.m_value.boolean
14122 ? to_char_type(0xF5)
14123 : to_char_type(0xF4));
14127 case value_t::number_integer:
14129 if (j.m_value.number_integer >= 0)
14134 if (j.m_value.number_integer <= 0x17)
14136 write_number(
static_cast<std::uint8_t
>(j.m_value.number_integer));
14138 else if (j.m_value.number_integer <= (std::numeric_limits<std::uint8_t>::max)())
14140 oa->write_character(to_char_type(0x18));
14141 write_number(
static_cast<std::uint8_t
>(j.m_value.number_integer));
14143 else if (j.m_value.number_integer <= (std::numeric_limits<std::uint16_t>::max)())
14145 oa->write_character(to_char_type(0x19));
14146 write_number(
static_cast<std::uint16_t
>(j.m_value.number_integer));
14148 else if (j.m_value.number_integer <= (std::numeric_limits<std::uint32_t>::max)())
14150 oa->write_character(to_char_type(0x1A));
14151 write_number(
static_cast<std::uint32_t
>(j.m_value.number_integer));
14155 oa->write_character(to_char_type(0x1B));
14156 write_number(
static_cast<std::uint64_t
>(j.m_value.number_integer));
14163 const auto positive_number = -1 - j.m_value.number_integer;
14164 if (j.m_value.number_integer >= -24)
14166 write_number(
static_cast<std::uint8_t
>(0x20 + positive_number));
14168 else if (positive_number <= (std::numeric_limits<std::uint8_t>::max)())
14170 oa->write_character(to_char_type(0x38));
14171 write_number(
static_cast<std::uint8_t
>(positive_number));
14173 else if (positive_number <= (std::numeric_limits<std::uint16_t>::max)())
14175 oa->write_character(to_char_type(0x39));
14176 write_number(
static_cast<std::uint16_t
>(positive_number));
14178 else if (positive_number <= (std::numeric_limits<std::uint32_t>::max)())
14180 oa->write_character(to_char_type(0x3A));
14181 write_number(
static_cast<std::uint32_t
>(positive_number));
14185 oa->write_character(to_char_type(0x3B));
14186 write_number(
static_cast<std::uint64_t
>(positive_number));
14192 case value_t::number_unsigned:
14194 if (j.m_value.number_unsigned <= 0x17)
14196 write_number(
static_cast<std::uint8_t
>(j.m_value.number_unsigned));
14198 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)())
14200 oa->write_character(to_char_type(0x18));
14201 write_number(
static_cast<std::uint8_t
>(j.m_value.number_unsigned));
14203 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)())
14205 oa->write_character(to_char_type(0x19));
14206 write_number(
static_cast<std::uint16_t
>(j.m_value.number_unsigned));
14208 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)())
14210 oa->write_character(to_char_type(0x1A));
14211 write_number(
static_cast<std::uint32_t
>(j.m_value.number_unsigned));
14215 oa->write_character(to_char_type(0x1B));
14216 write_number(
static_cast<std::uint64_t
>(j.m_value.number_unsigned));
14221 case value_t::number_float:
14223 if (std::isnan(j.m_value.number_float))
14226 oa->write_character(to_char_type(0xF9));
14227 oa->write_character(to_char_type(0x7E));
14228 oa->write_character(to_char_type(0x00));
14230 else if (std::isinf(j.m_value.number_float))
14233 oa->write_character(to_char_type(0xf9));
14234 oa->write_character(j.m_value.number_float > 0 ? to_char_type(0x7C) : to_char_type(0xFC));
14235 oa->write_character(to_char_type(0x00));
14239 write_compact_float(j.m_value.number_float, detail::input_format_t::cbor);
14244 case value_t::string:
14247 const auto N = j.m_value.string->size();
14250 write_number(
static_cast<std::uint8_t
>(0x60 + N));
14252 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
14254 oa->write_character(to_char_type(0x78));
14255 write_number(
static_cast<std::uint8_t
>(N));
14257 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
14259 oa->write_character(to_char_type(0x79));
14260 write_number(
static_cast<std::uint16_t
>(N));
14262 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
14264 oa->write_character(to_char_type(0x7A));
14265 write_number(
static_cast<std::uint32_t
>(N));
14268 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
14270 oa->write_character(to_char_type(0x7B));
14271 write_number(
static_cast<std::uint64_t
>(N));
14276 oa->write_characters(
14277 reinterpret_cast<const CharType*
>(j.m_value.string->c_str()),
14278 j.m_value.string->size());
14282 case value_t::array:
14285 const auto N = j.m_value.array->size();
14288 write_number(
static_cast<std::uint8_t
>(0x80 + N));
14290 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
14292 oa->write_character(to_char_type(0x98));
14293 write_number(
static_cast<std::uint8_t
>(N));
14295 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
14297 oa->write_character(to_char_type(0x99));
14298 write_number(
static_cast<std::uint16_t
>(N));
14300 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
14302 oa->write_character(to_char_type(0x9A));
14303 write_number(
static_cast<std::uint32_t
>(N));
14306 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
14308 oa->write_character(to_char_type(0x9B));
14309 write_number(
static_cast<std::uint64_t
>(N));
14314 for (
const auto& el : *j.m_value.array)
14321 case value_t::binary:
14323 if (j.m_value.binary->has_subtype())
14325 if (j.m_value.binary->subtype() <= (std::numeric_limits<std::uint8_t>::max)())
14327 write_number(
static_cast<std::uint8_t
>(0xd8));
14328 write_number(
static_cast<std::uint8_t
>(j.m_value.binary->subtype()));
14330 else if (j.m_value.binary->subtype() <= (std::numeric_limits<std::uint16_t>::max)())
14332 write_number(
static_cast<std::uint8_t
>(0xd9));
14333 write_number(
static_cast<std::uint16_t
>(j.m_value.binary->subtype()));
14335 else if (j.m_value.binary->subtype() <= (std::numeric_limits<std::uint32_t>::max)())
14337 write_number(
static_cast<std::uint8_t
>(0xda));
14338 write_number(
static_cast<std::uint32_t
>(j.m_value.binary->subtype()));
14340 else if (j.m_value.binary->subtype() <= (std::numeric_limits<std::uint64_t>::max)())
14342 write_number(
static_cast<std::uint8_t
>(0xdb));
14343 write_number(
static_cast<std::uint64_t
>(j.m_value.binary->subtype()));
14348 const auto N = j.m_value.binary->size();
14351 write_number(
static_cast<std::uint8_t
>(0x40 + N));
14353 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
14355 oa->write_character(to_char_type(0x58));
14356 write_number(
static_cast<std::uint8_t
>(N));
14358 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
14360 oa->write_character(to_char_type(0x59));
14361 write_number(
static_cast<std::uint16_t
>(N));
14363 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
14365 oa->write_character(to_char_type(0x5A));
14366 write_number(
static_cast<std::uint32_t
>(N));
14369 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
14371 oa->write_character(to_char_type(0x5B));
14372 write_number(
static_cast<std::uint64_t
>(N));
14377 oa->write_characters(
14378 reinterpret_cast<const CharType*
>(j.m_value.binary->data()),
14384 case value_t::object:
14387 const auto N = j.m_value.object->size();
14390 write_number(
static_cast<std::uint8_t
>(0xA0 + N));
14392 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
14394 oa->write_character(to_char_type(0xB8));
14395 write_number(
static_cast<std::uint8_t
>(N));
14397 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
14399 oa->write_character(to_char_type(0xB9));
14400 write_number(
static_cast<std::uint16_t
>(N));
14402 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
14404 oa->write_character(to_char_type(0xBA));
14405 write_number(
static_cast<std::uint32_t
>(N));
14408 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
14410 oa->write_character(to_char_type(0xBB));
14411 write_number(
static_cast<std::uint64_t
>(N));
14416 for (
const auto& el : *j.m_value.object)
14418 write_cbor(el.first);
14419 write_cbor(el.second);
14424 case value_t::discarded:
14437 case value_t::null:
14439 oa->write_character(to_char_type(0xC0));
14443 case value_t::boolean:
14445 oa->write_character(j.m_value.boolean
14446 ? to_char_type(0xC3)
14447 : to_char_type(0xC2));
14451 case value_t::number_integer:
14453 if (j.m_value.number_integer >= 0)
14458 if (j.m_value.number_unsigned < 128)
14461 write_number(
static_cast<std::uint8_t
>(j.m_value.number_integer));
14463 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)())
14466 oa->write_character(to_char_type(0xCC));
14467 write_number(
static_cast<std::uint8_t
>(j.m_value.number_integer));
14469 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)())
14472 oa->write_character(to_char_type(0xCD));
14473 write_number(
static_cast<std::uint16_t
>(j.m_value.number_integer));
14475 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)())
14478 oa->write_character(to_char_type(0xCE));
14479 write_number(
static_cast<std::uint32_t
>(j.m_value.number_integer));
14481 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint64_t>::max)())
14484 oa->write_character(to_char_type(0xCF));
14485 write_number(
static_cast<std::uint64_t
>(j.m_value.number_integer));
14490 if (j.m_value.number_integer >= -32)
14493 write_number(
static_cast<std::int8_t
>(j.m_value.number_integer));
14495 else if (j.m_value.number_integer >= (std::numeric_limits<std::int8_t>::min)() &&
14496 j.m_value.number_integer <= (std::numeric_limits<std::int8_t>::max)())
14499 oa->write_character(to_char_type(0xD0));
14500 write_number(
static_cast<std::int8_t
>(j.m_value.number_integer));
14502 else if (j.m_value.number_integer >= (std::numeric_limits<std::int16_t>::min)() &&
14503 j.m_value.number_integer <= (std::numeric_limits<std::int16_t>::max)())
14506 oa->write_character(to_char_type(0xD1));
14507 write_number(
static_cast<std::int16_t
>(j.m_value.number_integer));
14509 else if (j.m_value.number_integer >= (std::numeric_limits<std::int32_t>::min)() &&
14510 j.m_value.number_integer <= (std::numeric_limits<std::int32_t>::max)())
14513 oa->write_character(to_char_type(0xD2));
14514 write_number(
static_cast<std::int32_t
>(j.m_value.number_integer));
14516 else if (j.m_value.number_integer >= (std::numeric_limits<std::int64_t>::min)() &&
14517 j.m_value.number_integer <= (std::numeric_limits<std::int64_t>::max)())
14520 oa->write_character(to_char_type(0xD3));
14521 write_number(
static_cast<std::int64_t
>(j.m_value.number_integer));
14527 case value_t::number_unsigned:
14529 if (j.m_value.number_unsigned < 128)
14532 write_number(
static_cast<std::uint8_t
>(j.m_value.number_integer));
14534 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)())
14537 oa->write_character(to_char_type(0xCC));
14538 write_number(
static_cast<std::uint8_t
>(j.m_value.number_integer));
14540 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)())
14543 oa->write_character(to_char_type(0xCD));
14544 write_number(
static_cast<std::uint16_t
>(j.m_value.number_integer));
14546 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)())
14549 oa->write_character(to_char_type(0xCE));
14550 write_number(
static_cast<std::uint32_t
>(j.m_value.number_integer));
14552 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint64_t>::max)())
14555 oa->write_character(to_char_type(0xCF));
14556 write_number(
static_cast<std::uint64_t
>(j.m_value.number_integer));
14561 case value_t::number_float:
14563 write_compact_float(j.m_value.number_float, detail::input_format_t::msgpack);
14567 case value_t::string:
14570 const auto N = j.m_value.string->size();
14574 write_number(
static_cast<std::uint8_t
>(0xA0 | N));
14576 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
14579 oa->write_character(to_char_type(0xD9));
14580 write_number(
static_cast<std::uint8_t
>(N));
14582 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
14585 oa->write_character(to_char_type(0xDA));
14586 write_number(
static_cast<std::uint16_t
>(N));
14588 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
14591 oa->write_character(to_char_type(0xDB));
14592 write_number(
static_cast<std::uint32_t
>(N));
14596 oa->write_characters(
14597 reinterpret_cast<const CharType*
>(j.m_value.string->c_str()),
14598 j.m_value.string->size());
14602 case value_t::array:
14605 const auto N = j.m_value.array->size();
14609 write_number(
static_cast<std::uint8_t
>(0x90 | N));
14611 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
14614 oa->write_character(to_char_type(0xDC));
14615 write_number(
static_cast<std::uint16_t
>(N));
14617 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
14620 oa->write_character(to_char_type(0xDD));
14621 write_number(
static_cast<std::uint32_t
>(N));
14625 for (
const auto& el : *j.m_value.array)
14632 case value_t::binary:
14636 const bool use_ext = j.m_value.binary->has_subtype();
14639 const auto N = j.m_value.binary->size();
14640 if (N <= (std::numeric_limits<std::uint8_t>::max)())
14642 std::uint8_t output_type{};
14649 output_type = 0xD4;
14652 output_type = 0xD5;
14655 output_type = 0xD6;
14658 output_type = 0xD7;
14661 output_type = 0xD8;
14664 output_type = 0xC7;
14672 output_type = 0xC4;
14676 oa->write_character(to_char_type(output_type));
14679 write_number(
static_cast<std::uint8_t
>(N));
14682 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
14684 std::uint8_t output_type = use_ext
14688 oa->write_character(to_char_type(output_type));
14689 write_number(
static_cast<std::uint16_t
>(N));
14691 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
14693 std::uint8_t output_type = use_ext
14697 oa->write_character(to_char_type(output_type));
14698 write_number(
static_cast<std::uint32_t
>(N));
14704 write_number(
static_cast<std::int8_t
>(j.m_value.binary->subtype()));
14708 oa->write_characters(
14709 reinterpret_cast<const CharType*
>(j.m_value.binary->data()),
14715 case value_t::object:
14718 const auto N = j.m_value.object->size();
14722 write_number(
static_cast<std::uint8_t
>(0x80 | (N & 0xF)));
14724 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
14727 oa->write_character(to_char_type(0xDE));
14728 write_number(
static_cast<std::uint16_t
>(N));
14730 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
14733 oa->write_character(to_char_type(0xDF));
14734 write_number(
static_cast<std::uint32_t
>(N));
14738 for (
const auto& el : *j.m_value.object)
14740 write_msgpack(el.first);
14741 write_msgpack(el.second);
14746 case value_t::discarded:
14760 const bool use_type,
const bool add_prefix =
true,
14761 const bool use_bjdata =
false)
14765 case value_t::null:
14769 oa->write_character(to_char_type(
'Z'));
14774 case value_t::boolean:
14778 oa->write_character(j.m_value.boolean
14779 ? to_char_type(
'T')
14780 : to_char_type(
'F'));
14785 case value_t::number_integer:
14787 write_number_with_ubjson_prefix(j.m_value.number_integer, add_prefix, use_bjdata);
14791 case value_t::number_unsigned:
14793 write_number_with_ubjson_prefix(j.m_value.number_unsigned, add_prefix, use_bjdata);
14797 case value_t::number_float:
14799 write_number_with_ubjson_prefix(j.m_value.number_float, add_prefix, use_bjdata);
14803 case value_t::string:
14807 oa->write_character(to_char_type(
'S'));
14809 write_number_with_ubjson_prefix(j.m_value.string->size(),
true, use_bjdata);
14810 oa->write_characters(
14811 reinterpret_cast<const CharType*
>(j.m_value.string->c_str()),
14812 j.m_value.string->size());
14816 case value_t::array:
14820 oa->write_character(to_char_type(
'['));
14823 bool prefix_required =
true;
14824 if (use_type && !j.m_value.array->empty())
14827 const CharType first_prefix = ubjson_prefix(j.front(), use_bjdata);
14828 const bool same_prefix = std::all_of(j.begin() + 1, j.end(),
14829 [
this, first_prefix, use_bjdata](
const BasicJsonType & v)
14831 return ubjson_prefix(v, use_bjdata) == first_prefix;
14834 std::vector<CharType> bjdx = {
'[',
'{',
'S',
'H',
'T',
'F',
'N',
'Z'};
14836 if (same_prefix && !(use_bjdata && std::find(bjdx.begin(), bjdx.end(), first_prefix) != bjdx.end()))
14838 prefix_required =
false;
14839 oa->write_character(to_char_type(
'$'));
14840 oa->write_character(first_prefix);
14846 oa->write_character(to_char_type(
'#'));
14847 write_number_with_ubjson_prefix(j.m_value.array->size(),
true, use_bjdata);
14850 for (
const auto& el : *j.m_value.array)
14852 write_ubjson(el, use_count, use_type, prefix_required, use_bjdata);
14857 oa->write_character(to_char_type(
']'));
14863 case value_t::binary:
14867 oa->write_character(to_char_type(
'['));
14870 if (use_type && !j.m_value.binary->empty())
14873 oa->write_character(to_char_type(
'$'));
14874 oa->write_character(
'U');
14879 oa->write_character(to_char_type(
'#'));
14880 write_number_with_ubjson_prefix(j.m_value.binary->size(),
true, use_bjdata);
14885 oa->write_characters(
14886 reinterpret_cast<const CharType*
>(j.m_value.binary->data()),
14887 j.m_value.binary->size());
14891 for (
size_t i = 0; i < j.m_value.binary->size(); ++i)
14893 oa->write_character(to_char_type(
'U'));
14894 oa->write_character(j.m_value.binary->data()[i]);
14900 oa->write_character(to_char_type(
']'));
14906 case value_t::object:
14908 if (use_bjdata && j.m_value.object->size() == 3 && j.m_value.object->find(
"_ArrayType_") != j.m_value.object->end() && j.m_value.object->find(
"_ArraySize_") != j.m_value.object->end() && j.m_value.object->find(
"_ArrayData_") != j.m_value.object->end())
14910 if (!write_bjdata_ndarray(*j.m_value.object, use_count, use_type))
14918 oa->write_character(to_char_type(
'{'));
14921 bool prefix_required =
true;
14922 if (use_type && !j.m_value.object->empty())
14925 const CharType first_prefix = ubjson_prefix(j.front(), use_bjdata);
14926 const bool same_prefix = std::all_of(j.begin(), j.end(),
14927 [
this, first_prefix, use_bjdata](
const BasicJsonType & v)
14929 return ubjson_prefix(v, use_bjdata) == first_prefix;
14932 std::vector<CharType> bjdx = {
'[',
'{',
'S',
'H',
'T',
'F',
'N',
'Z'};
14934 if (same_prefix && !(use_bjdata && std::find(bjdx.begin(), bjdx.end(), first_prefix) != bjdx.end()))
14936 prefix_required =
false;
14937 oa->write_character(to_char_type(
'$'));
14938 oa->write_character(first_prefix);
14944 oa->write_character(to_char_type(
'#'));
14945 write_number_with_ubjson_prefix(j.m_value.object->size(),
true, use_bjdata);
14948 for (
const auto& el : *j.m_value.object)
14950 write_number_with_ubjson_prefix(el.first.size(),
true, use_bjdata);
14951 oa->write_characters(
14952 reinterpret_cast<const CharType*
>(el.first.c_str()),
14954 write_ubjson(el.second, use_count, use_type, prefix_required, use_bjdata);
14959 oa->write_character(to_char_type(
'}'));
14965 case value_t::discarded:
14980 static std::size_t calc_bson_entry_header_size(
const string_t& name,
const BasicJsonType& j)
14982 const auto it = name.find(
static_cast<typename string_t::value_type
>(0));
14986 static_cast<void>(j);
14989 return 1ul + name.size() + 1u;
14995 void write_bson_entry_header(
const string_t& name,
14996 const std::uint8_t element_type)
14998 oa->write_character(to_char_type(element_type));
14999 oa->write_characters(
15000 reinterpret_cast<const CharType*
>(name.c_str()),
15007 void write_bson_boolean(
const string_t& name,
15010 write_bson_entry_header(name, 0x08);
15011 oa->write_character(value ? to_char_type(0x01) : to_char_type(0x00));
15017 void write_bson_double(
const string_t& name,
15018 const double value)
15020 write_bson_entry_header(name, 0x01);
15021 write_number<double>(value,
true);
15027 static std::size_t calc_bson_string_size(
const string_t& value)
15029 return sizeof(std::int32_t) +
value.size() + 1ul;
15035 void write_bson_string(
const string_t& name,
15036 const string_t& value)
15038 write_bson_entry_header(name, 0x02);
15040 write_number<std::int32_t>(
static_cast<std::int32_t
>(
value.size() + 1ul),
true);
15041 oa->write_characters(
15042 reinterpret_cast<const CharType*
>(
value.c_str()),
15049 void write_bson_null(
const string_t& name)
15051 write_bson_entry_header(name, 0x0A);
15057 static std::size_t calc_bson_integer_size(
const std::int64_t value)
15059 return (std::numeric_limits<std::int32_t>::min)() <= value && value <= (std::numeric_limits<std::int32_t>::max)()
15060 ?
sizeof(std::int32_t)
15061 :
sizeof(std::int64_t);
15067 void write_bson_integer(
const string_t& name,
15068 const std::int64_t value)
15070 if ((std::numeric_limits<std::int32_t>::min)() <= value && value <= (std::numeric_limits<std::int32_t>::max)())
15072 write_bson_entry_header(name, 0x10);
15073 write_number<std::int32_t>(
static_cast<std::int32_t
>(value),
true);
15077 write_bson_entry_header(name, 0x12);
15078 write_number<std::int64_t>(
static_cast<std::int64_t
>(value),
true);
15085 static constexpr std::size_t calc_bson_unsigned_size(
const std::uint64_t value)
noexcept
15087 return (value <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int32_t>::max)()))
15088 ?
sizeof(std::int32_t)
15089 :
sizeof(std::int64_t);
15095 void write_bson_unsigned(
const string_t& name,
15096 const BasicJsonType& j)
15098 if (j.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int32_t>::max)()))
15100 write_bson_entry_header(name, 0x10 );
15101 write_number<std::int32_t>(
static_cast<std::int32_t
>(j.m_value.number_unsigned),
true);
15103 else if (j.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int64_t>::max)()))
15105 write_bson_entry_header(name, 0x12 );
15106 write_number<std::int64_t>(
static_cast<std::int64_t
>(j.m_value.number_unsigned),
true);
15110 JSON_THROW(out_of_range::create(407,
concat(
"integer number ",
std::to_string(j.m_value.number_unsigned),
" cannot be represented by BSON as it does not fit int64"), &j));
15117 void write_bson_object_entry(
const string_t& name,
15118 const typename BasicJsonType::object_t& value)
15120 write_bson_entry_header(name, 0x03);
15121 write_bson_object(value);
15127 static std::size_t calc_bson_array_size(
const typename BasicJsonType::array_t& value)
15129 std::size_t array_index = 0ul;
15131 const std::size_t embedded_document_size = std::accumulate(std::begin(value), std::end(value),
static_cast<std::size_t
>(0), [&array_index](std::size_t result,
const typename BasicJsonType::array_t::value_type & el)
15133 return result + calc_bson_element_size(
std::to_string(array_index++), el);
15136 return sizeof(std::int32_t) + embedded_document_size + 1ul;
15142 static std::size_t calc_bson_binary_size(
const typename BasicJsonType::binary_t& value)
15144 return sizeof(std::int32_t) +
value.size() + 1ul;
15150 void write_bson_array(
const string_t& name,
15151 const typename BasicJsonType::array_t& value)
15153 write_bson_entry_header(name, 0x04);
15154 write_number<std::int32_t>(
static_cast<std::int32_t
>(calc_bson_array_size(value)),
true);
15156 std::size_t array_index = 0ul;
15158 for (
const auto& el : value)
15163 oa->write_character(to_char_type(0x00));
15169 void write_bson_binary(
const string_t& name,
15170 const binary_t& value)
15172 write_bson_entry_header(name, 0x05);
15174 write_number<std::int32_t>(
static_cast<std::int32_t
>(
value.size()),
true);
15175 write_number(
value.has_subtype() ?
static_cast<std::uint8_t
>(
value.subtype()) :
static_cast<std::uint8_t
>(0x00));
15177 oa->write_characters(
reinterpret_cast<const CharType*
>(
value.data()),
value.size());
15184 static std::size_t calc_bson_element_size(
const string_t& name,
15185 const BasicJsonType& j)
15187 const auto header_size = calc_bson_entry_header_size(name, j);
15190 case value_t::object:
15191 return header_size + calc_bson_object_size(*j.m_value.object);
15193 case value_t::array:
15194 return header_size + calc_bson_array_size(*j.m_value.array);
15196 case value_t::binary:
15197 return header_size + calc_bson_binary_size(*j.m_value.binary);
15199 case value_t::boolean:
15200 return header_size + 1ul;
15202 case value_t::number_float:
15203 return header_size + 8ul;
15205 case value_t::number_integer:
15206 return header_size + calc_bson_integer_size(j.m_value.number_integer);
15208 case value_t::number_unsigned:
15209 return header_size + calc_bson_unsigned_size(j.m_value.number_unsigned);
15211 case value_t::string:
15212 return header_size + calc_bson_string_size(*j.m_value.string);
15214 case value_t::null:
15215 return header_size + 0ul;
15218 case value_t::discarded:
15232 void write_bson_element(
const string_t& name,
15233 const BasicJsonType& j)
15237 case value_t::object:
15238 return write_bson_object_entry(name, *j.m_value.object);
15240 case value_t::array:
15241 return write_bson_array(name, *j.m_value.array);
15243 case value_t::binary:
15244 return write_bson_binary(name, *j.m_value.binary);
15246 case value_t::boolean:
15247 return write_bson_boolean(name, j.m_value.boolean);
15249 case value_t::number_float:
15250 return write_bson_double(name, j.m_value.number_float);
15252 case value_t::number_integer:
15253 return write_bson_integer(name, j.m_value.number_integer);
15255 case value_t::number_unsigned:
15256 return write_bson_unsigned(name, j);
15258 case value_t::string:
15259 return write_bson_string(name, *j.m_value.string);
15261 case value_t::null:
15262 return write_bson_null(name);
15265 case value_t::discarded:
15279 static std::size_t calc_bson_object_size(
const typename BasicJsonType::object_t& value)
15281 std::size_t document_size = std::accumulate(
value.begin(),
value.end(),
static_cast<std::size_t
>(0),
15282 [](
size_t result,
const typename BasicJsonType::object_t::value_type & el)
15284 return result += calc_bson_element_size(el.first, el.second);
15287 return sizeof(std::int32_t) + document_size + 1ul;
15294 void write_bson_object(
const typename BasicJsonType::object_t& value)
15296 write_number<std::int32_t>(
static_cast<std::int32_t
>(calc_bson_object_size(value)),
true);
15298 for (
const auto& el : value)
15300 write_bson_element(el.first, el.second);
15303 oa->write_character(to_char_type(0x00));
15310 static constexpr CharType get_cbor_float_prefix(
float )
15312 return to_char_type(0xFA);
15315 static constexpr CharType get_cbor_float_prefix(
double )
15317 return to_char_type(0xFB);
15324 static constexpr CharType get_msgpack_float_prefix(
float )
15326 return to_char_type(0xCA);
15329 static constexpr CharType get_msgpack_float_prefix(
double )
15331 return to_char_type(0xCB);
15339 template<
typename NumberType,
typename std::enable_if<
15340 std::is_floating_point<NumberType>::value,
int>::type = 0>
15341 void write_number_with_ubjson_prefix(
const NumberType n,
15342 const bool add_prefix,
15343 const bool use_bjdata)
15347 oa->write_character(get_ubjson_float_prefix(n));
15349 write_number(n, use_bjdata);
15353 template<
typename NumberType,
typename std::enable_if<
15354 std::is_unsigned<NumberType>::value,
int>::type = 0>
15355 void write_number_with_ubjson_prefix(
const NumberType n,
15356 const bool add_prefix,
15357 const bool use_bjdata)
15359 if (n <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int8_t>::max)()))
15363 oa->write_character(to_char_type(
'i'));
15365 write_number(
static_cast<std::uint8_t
>(n), use_bjdata);
15367 else if (n <= (std::numeric_limits<std::uint8_t>::max)())
15371 oa->write_character(to_char_type(
'U'));
15373 write_number(
static_cast<std::uint8_t
>(n), use_bjdata);
15375 else if (n <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int16_t>::max)()))
15379 oa->write_character(to_char_type(
'I'));
15381 write_number(
static_cast<std::int16_t
>(n), use_bjdata);
15383 else if (use_bjdata && n <=
static_cast<uint64_t
>((std::numeric_limits<uint16_t>::max)()))
15387 oa->write_character(to_char_type(
'u'));
15389 write_number(
static_cast<std::uint16_t
>(n), use_bjdata);
15391 else if (n <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int32_t>::max)()))
15395 oa->write_character(to_char_type(
'l'));
15397 write_number(
static_cast<std::int32_t
>(n), use_bjdata);
15399 else if (use_bjdata && n <=
static_cast<uint64_t
>((std::numeric_limits<uint32_t>::max)()))
15403 oa->write_character(to_char_type(
'm'));
15405 write_number(
static_cast<std::uint32_t
>(n), use_bjdata);
15407 else if (n <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int64_t>::max)()))
15411 oa->write_character(to_char_type(
'L'));
15413 write_number(
static_cast<std::int64_t
>(n), use_bjdata);
15415 else if (use_bjdata && n <= (std::numeric_limits<uint64_t>::max)())
15419 oa->write_character(to_char_type(
'M'));
15421 write_number(
static_cast<std::uint64_t
>(n), use_bjdata);
15427 oa->write_character(to_char_type(
'H'));
15430 const auto number = BasicJsonType(n).dump();
15431 write_number_with_ubjson_prefix(number.size(),
true, use_bjdata);
15432 for (std::size_t i = 0; i < number.size(); ++i)
15434 oa->write_character(to_char_type(
static_cast<std::uint8_t
>(number[i])));
15440 template <
typename NumberType,
typename std::enable_if <
15441 std::is_signed<NumberType>::value&&
15442 !std::is_floating_point<NumberType>::value,
int >::type = 0 >
15443 void write_number_with_ubjson_prefix(
const NumberType n,
15444 const bool add_prefix,
15445 const bool use_bjdata)
15447 if ((std::numeric_limits<std::int8_t>::min)() <= n && n <= (std::numeric_limits<std::int8_t>::max)())
15451 oa->write_character(to_char_type(
'i'));
15453 write_number(
static_cast<std::int8_t
>(n), use_bjdata);
15455 else if (
static_cast<std::int64_t
>((std::numeric_limits<std::uint8_t>::min)()) <= n && n <=
static_cast<std::int64_t
>((std::numeric_limits<std::uint8_t>::max)()))
15459 oa->write_character(to_char_type(
'U'));
15461 write_number(
static_cast<std::uint8_t
>(n), use_bjdata);
15463 else if ((std::numeric_limits<std::int16_t>::min)() <= n && n <= (std::numeric_limits<std::int16_t>::max)())
15467 oa->write_character(to_char_type(
'I'));
15469 write_number(
static_cast<std::int16_t
>(n), use_bjdata);
15471 else if (use_bjdata && (
static_cast<std::int64_t
>((std::numeric_limits<std::uint16_t>::min)()) <= n && n <=
static_cast<std::int64_t
>((std::numeric_limits<std::uint16_t>::max)())))
15475 oa->write_character(to_char_type(
'u'));
15477 write_number(
static_cast<uint16_t
>(n), use_bjdata);
15479 else if ((std::numeric_limits<std::int32_t>::min)() <= n && n <= (std::numeric_limits<std::int32_t>::max)())
15483 oa->write_character(to_char_type(
'l'));
15485 write_number(
static_cast<std::int32_t
>(n), use_bjdata);
15487 else if (use_bjdata && (
static_cast<std::int64_t
>((std::numeric_limits<std::uint32_t>::min)()) <= n && n <=
static_cast<std::int64_t
>((std::numeric_limits<std::uint32_t>::max)())))
15491 oa->write_character(to_char_type(
'm'));
15493 write_number(
static_cast<uint32_t
>(n), use_bjdata);
15495 else if ((std::numeric_limits<std::int64_t>::min)() <= n && n <= (std::numeric_limits<std::int64_t>::max)())
15499 oa->write_character(to_char_type(
'L'));
15501 write_number(
static_cast<std::int64_t
>(n), use_bjdata);
15508 oa->write_character(to_char_type(
'H'));
15511 const auto number = BasicJsonType(n).dump();
15512 write_number_with_ubjson_prefix(number.size(),
true, use_bjdata);
15513 for (std::size_t i = 0; i < number.size(); ++i)
15515 oa->write_character(to_char_type(
static_cast<std::uint8_t
>(number[i])));
15524 CharType ubjson_prefix(
const BasicJsonType& j,
const bool use_bjdata)
const noexcept
15528 case value_t::null:
15531 case value_t::boolean:
15532 return j.m_value.boolean ?
'T' :
'F';
15534 case value_t::number_integer:
15536 if ((std::numeric_limits<std::int8_t>::min)() <= j.m_value.number_integer && j.m_value.number_integer <= (std::numeric_limits<std::int8_t>::max)())
15540 if ((std::numeric_limits<std::uint8_t>::min)() <= j.m_value.number_integer && j.m_value.number_integer <= (std::numeric_limits<std::uint8_t>::max)())
15544 if ((std::numeric_limits<std::int16_t>::min)() <= j.m_value.number_integer && j.m_value.number_integer <= (std::numeric_limits<std::int16_t>::max)())
15548 if (use_bjdata && ((std::numeric_limits<std::uint16_t>::min)() <= j.m_value.number_integer && j.m_value.number_integer <= (std::numeric_limits<std::uint16_t>::max)()))
15552 if ((std::numeric_limits<std::int32_t>::min)() <= j.m_value.number_integer && j.m_value.number_integer <= (std::numeric_limits<std::int32_t>::max)())
15556 if (use_bjdata && ((std::numeric_limits<std::uint32_t>::min)() <= j.m_value.number_integer && j.m_value.number_integer <= (std::numeric_limits<std::uint32_t>::max)()))
15560 if ((std::numeric_limits<std::int64_t>::min)() <= j.m_value.number_integer && j.m_value.number_integer <= (std::numeric_limits<std::int64_t>::max)())
15568 case value_t::number_unsigned:
15570 if (j.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int8_t>::max)()))
15574 if (j.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::uint8_t>::max)()))
15578 if (j.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int16_t>::max)()))
15582 if (use_bjdata && j.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::uint16_t>::max)()))
15586 if (j.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int32_t>::max)()))
15590 if (use_bjdata && j.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::uint32_t>::max)()))
15594 if (j.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int64_t>::max)()))
15598 if (use_bjdata && j.m_value.number_unsigned <= (std::numeric_limits<std::uint64_t>::max)())
15606 case value_t::number_float:
15607 return get_ubjson_float_prefix(j.m_value.number_float);
15609 case value_t::string:
15612 case value_t::array:
15613 case value_t::binary:
15616 case value_t::object:
15619 case value_t::discarded:
15625 static constexpr CharType get_ubjson_float_prefix(
float )
15630 static constexpr CharType get_ubjson_float_prefix(
double )
15638 bool write_bjdata_ndarray(
const typename BasicJsonType::object_t& value,
const bool use_count,
const bool use_type)
15640 std::map<string_t, CharType> bjdtype = {{
"uint8",
'U'}, {
"int8",
'i'}, {
"uint16",
'u'}, {
"int16",
'I'},
15641 {
"uint32",
'm'}, {
"int32",
'l'}, {
"uint64",
'M'}, {
"int64",
'L'}, {
"single",
'd'}, {
"double",
'D'}, {
"char",
'C'}
15644 string_t
key =
"_ArrayType_";
15645 auto it = bjdtype.find(
static_cast<string_t
>(
value.at(key)));
15646 if (it == bjdtype.end())
15650 CharType dtype = it->second;
15652 key =
"_ArraySize_";
15653 std::size_t len = (
value.at(key).empty() ? 0 : 1);
15654 for (
const auto& el :
value.at(key))
15656 len *=
static_cast<std::size_t
>(el.m_value.number_unsigned);
15659 key =
"_ArrayData_";
15660 if (
value.at(key).size() != len)
15665 oa->write_character(
'[');
15666 oa->write_character(
'$');
15667 oa->write_character(dtype);
15668 oa->write_character(
'#');
15670 key =
"_ArraySize_";
15671 write_ubjson(
value.at(key), use_count, use_type,
true,
true);
15673 key =
"_ArrayData_";
15674 if (dtype ==
'U' || dtype ==
'C')
15676 for (
const auto& el :
value.at(key))
15678 write_number(
static_cast<std::uint8_t
>(el.m_value.number_unsigned),
true);
15681 else if (dtype ==
'i')
15683 for (
const auto& el :
value.at(key))
15685 write_number(
static_cast<std::int8_t
>(el.m_value.number_integer),
true);
15688 else if (dtype ==
'u')
15690 for (
const auto& el :
value.at(key))
15692 write_number(
static_cast<std::uint16_t
>(el.m_value.number_unsigned),
true);
15695 else if (dtype ==
'I')
15697 for (
const auto& el :
value.at(key))
15699 write_number(
static_cast<std::int16_t
>(el.m_value.number_integer),
true);
15702 else if (dtype ==
'm')
15704 for (
const auto& el :
value.at(key))
15706 write_number(
static_cast<std::uint32_t
>(el.m_value.number_unsigned),
true);
15709 else if (dtype ==
'l')
15711 for (
const auto& el :
value.at(key))
15713 write_number(
static_cast<std::int32_t
>(el.m_value.number_integer),
true);
15716 else if (dtype ==
'M')
15718 for (
const auto& el :
value.at(key))
15720 write_number(
static_cast<std::uint64_t
>(el.m_value.number_unsigned),
true);
15723 else if (dtype ==
'L')
15725 for (
const auto& el :
value.at(key))
15727 write_number(
static_cast<std::int64_t
>(el.m_value.number_integer),
true);
15730 else if (dtype ==
'd')
15732 for (
const auto& el :
value.at(key))
15734 write_number(
static_cast<float>(el.m_value.number_float),
true);
15737 else if (dtype ==
'D')
15739 for (
const auto& el :
value.at(key))
15741 write_number(
static_cast<double>(el.m_value.number_float),
true);
15764 template<
typename NumberType>
15765 void write_number(
const NumberType n,
const bool OutputIsLittleEndian =
false)
15768 std::array<CharType,
sizeof(NumberType)> vec{};
15769 std::memcpy(vec.data(), &n,
sizeof(NumberType));
15772 if (is_little_endian != OutputIsLittleEndian)
15775 std::reverse(vec.begin(), vec.end());
15778 oa->write_characters(vec.data(),
sizeof(NumberType));
15784#pragma GCC diagnostic push
15785#pragma GCC diagnostic ignored "-Wfloat-equal"
15787 if (
static_cast<double>(n) >=
static_cast<double>(std::numeric_limits<float>::lowest()) &&
15788 static_cast<double>(n) <=
static_cast<double>((std::numeric_limits<float>::max)()) &&
15789 static_cast<double>(
static_cast<float>(n)) ==
static_cast<double>(n))
15791 oa->write_character(format == detail::input_format_t::cbor
15792 ? get_cbor_float_prefix(
static_cast<float>(n))
15793 : get_msgpack_float_prefix(
static_cast<float>(n)));
15794 write_number(
static_cast<float>(n));
15798 oa->write_character(format == detail::input_format_t::cbor
15799 ? get_cbor_float_prefix(n)
15800 : get_msgpack_float_prefix(n));
15804#pragma GCC diagnostic pop
15813 template <
typename C = CharType,
15814 enable_if_t < std::is_signed<C>::value && std::is_signed<char>::value > * =
nullptr >
15817 return *
reinterpret_cast<char*
>(&x);
15820 template <
typename C = CharType,
15824 static_assert(
sizeof(std::uint8_t) ==
sizeof(CharType),
"size of CharType must be equal to std::uint8_t");
15825 static_assert(std::is_trivial<CharType>::value,
"CharType must be trivial");
15827 std::memcpy(&result, &x,
sizeof(x));
15831 template<
typename C = CharType,
15838 template <
typename InputCharType,
typename C = CharType,
15840 std::is_signed<C>::value &&
15841 std::is_signed<char>::value &&
15842 std::is_same<char, typename std::remove_cv<InputCharType>::type>::value
15851 const bool is_little_endian = little_endianness();
15864#include <algorithm>
15874#include <type_traits>
15885#include <type_traits>
15917template<
typename Target,
typename Source>
15920 static_assert(
sizeof(Target) ==
sizeof(Source),
"size mismatch");
15923 std::memcpy(&target, &source,
sizeof(Source));
15934 constexpr diyfp(std::uint64_t f_,
int e_) noexcept :
f(f_),
e(e_) {}
15945 return {x.f - y.f, x.e};
15954 static_assert(
kPrecision == 64,
"internal error");
15979 const std::uint64_t u_lo = x.
f & 0xFFFFFFFFu;
15980 const std::uint64_t u_hi = x.f >> 32u;
15981 const std::uint64_t v_lo = y.f & 0xFFFFFFFFu;
15982 const std::uint64_t v_hi = y.f >> 32u;
15984 const std::uint64_t p0 = u_lo * v_lo;
15985 const std::uint64_t p1 = u_lo * v_hi;
15986 const std::uint64_t p2 = u_hi * v_lo;
15987 const std::uint64_t p3 = u_hi * v_hi;
15989 const std::uint64_t p0_hi = p0 >> 32u;
15990 const std::uint64_t p1_lo = p1 & 0xFFFFFFFFu;
15991 const std::uint64_t p1_hi = p1 >> 32u;
15992 const std::uint64_t p2_lo = p2 & 0xFFFFFFFFu;
15993 const std::uint64_t p2_hi = p2 >> 32u;
15995 std::uint64_t Q = p0_hi + p1_lo + p2_lo;
16006 Q += std::uint64_t{1} << (64u - 32u - 1u);
16008 const std::uint64_t h = p3 + p2_hi + p1_hi + (Q >> 32u);
16010 return {h, x.e + y.e + 64};
16021 while ((x.f >> 63u) == 0)
16036 const int delta = x.
e - target_exponent;
16041 return {x.f << delta, target_exponent};
16058template<
typename FloatType>
16071 static_assert(std::numeric_limits<FloatType>::is_iec559,
16072 "internal error: dtoa_short requires an IEEE-754 floating-point implementation");
16074 constexpr int kPrecision = std::numeric_limits<FloatType>::digits;
16075 constexpr int kBias = std::numeric_limits<FloatType>::max_exponent - 1 + (kPrecision - 1);
16076 constexpr int kMinExp = 1 - kBias;
16077 constexpr std::uint64_t kHiddenBit = std::uint64_t{1} << (kPrecision - 1);
16079 using bits_type =
typename std::conditional<kPrecision == 24, std::uint32_t, std::uint64_t >::type;
16081 const auto bits =
static_cast<std::uint64_t
>(reinterpret_bits<bits_type>(
value));
16082 const std::uint64_t E = bits >> (kPrecision - 1);
16083 const std::uint64_t F = bits & (kHiddenBit - 1);
16085 const bool is_denormal = E == 0;
16086 const diyfp v = is_denormal
16087 ?
diyfp(F, kMinExp)
16088 :
diyfp(F + kHiddenBit,
static_cast<int>(E) - kBias);
16111 const bool lower_boundary_is_closer = F == 0 && E > 1;
16113 const diyfp m_minus = lower_boundary_is_closer
16114 ?
diyfp(4 * v.
f - 1, v.
e - 2)
16115 :
diyfp(2 * v.
f - 1, v.
e - 1);
16250 constexpr int kCachedPowersMinDecExp = -300;
16251 constexpr int kCachedPowersDecStep = 8;
16253 static constexpr std::array<cached_power, 79> kCachedPowers =
16256 { 0xAB70FE17C79AC6CA, -1060, -300 },
16257 { 0xFF77B1FCBEBCDC4F, -1034, -292 },
16258 { 0xBE5691EF416BD60C, -1007, -284 },
16259 { 0x8DD01FAD907FFC3C, -980, -276 },
16260 { 0xD3515C2831559A83, -954, -268 },
16261 { 0x9D71AC8FADA6C9B5, -927, -260 },
16262 { 0xEA9C227723EE8BCB, -901, -252 },
16263 { 0xAECC49914078536D, -874, -244 },
16264 { 0x823C12795DB6CE57, -847, -236 },
16265 { 0xC21094364DFB5637, -821, -228 },
16266 { 0x9096EA6F3848984F, -794, -220 },
16267 { 0xD77485CB25823AC7, -768, -212 },
16268 { 0xA086CFCD97BF97F4, -741, -204 },
16269 { 0xEF340A98172AACE5, -715, -196 },
16270 { 0xB23867FB2A35B28E, -688, -188 },
16271 { 0x84C8D4DFD2C63F3B, -661, -180 },
16272 { 0xC5DD44271AD3CDBA, -635, -172 },
16273 { 0x936B9FCEBB25C996, -608, -164 },
16274 { 0xDBAC6C247D62A584, -582, -156 },
16275 { 0xA3AB66580D5FDAF6, -555, -148 },
16276 { 0xF3E2F893DEC3F126, -529, -140 },
16277 { 0xB5B5ADA8AAFF80B8, -502, -132 },
16278 { 0x87625F056C7C4A8B, -475, -124 },
16279 { 0xC9BCFF6034C13053, -449, -116 },
16280 { 0x964E858C91BA2655, -422, -108 },
16281 { 0xDFF9772470297EBD, -396, -100 },
16282 { 0xA6DFBD9FB8E5B88F, -369, -92 },
16283 { 0xF8A95FCF88747D94, -343, -84 },
16284 { 0xB94470938FA89BCF, -316, -76 },
16285 { 0x8A08F0F8BF0F156B, -289, -68 },
16286 { 0xCDB02555653131B6, -263, -60 },
16287 { 0x993FE2C6D07B7FAC, -236, -52 },
16288 { 0xE45C10C42A2B3B06, -210, -44 },
16289 { 0xAA242499697392D3, -183, -36 },
16290 { 0xFD87B5F28300CA0E, -157, -28 },
16291 { 0xBCE5086492111AEB, -130, -20 },
16292 { 0x8CBCCC096F5088CC, -103, -12 },
16293 { 0xD1B71758E219652C, -77, -4 },
16294 { 0x9C40000000000000, -50, 4 },
16295 { 0xE8D4A51000000000, -24, 12 },
16296 { 0xAD78EBC5AC620000, 3, 20 },
16297 { 0x813F3978F8940984, 30, 28 },
16298 { 0xC097CE7BC90715B3, 56, 36 },
16299 { 0x8F7E32CE7BEA5C70, 83, 44 },
16300 { 0xD5D238A4ABE98068, 109, 52 },
16301 { 0x9F4F2726179A2245, 136, 60 },
16302 { 0xED63A231D4C4FB27, 162, 68 },
16303 { 0xB0DE65388CC8ADA8, 189, 76 },
16304 { 0x83C7088E1AAB65DB, 216, 84 },
16305 { 0xC45D1DF942711D9A, 242, 92 },
16306 { 0x924D692CA61BE758, 269, 100 },
16307 { 0xDA01EE641A708DEA, 295, 108 },
16308 { 0xA26DA3999AEF774A, 322, 116 },
16309 { 0xF209787BB47D6B85, 348, 124 },
16310 { 0xB454E4A179DD1877, 375, 132 },
16311 { 0x865B86925B9BC5C2, 402, 140 },
16312 { 0xC83553C5C8965D3D, 428, 148 },
16313 { 0x952AB45CFA97A0B3, 455, 156 },
16314 { 0xDE469FBD99A05FE3, 481, 164 },
16315 { 0xA59BC234DB398C25, 508, 172 },
16316 { 0xF6C69A72A3989F5C, 534, 180 },
16317 { 0xB7DCBF5354E9BECE, 561, 188 },
16318 { 0x88FCF317F22241E2, 588, 196 },
16319 { 0xCC20CE9BD35C78A5, 614, 204 },
16320 { 0x98165AF37B2153DF, 641, 212 },
16321 { 0xE2A0B5DC971F303A, 667, 220 },
16322 { 0xA8D9D1535CE3B396, 694, 228 },
16323 { 0xFB9B7CD9A4A7443C, 720, 236 },
16324 { 0xBB764C4CA7A44410, 747, 244 },
16325 { 0x8BAB8EEFB6409C1A, 774, 252 },
16326 { 0xD01FEF10A657842C, 800, 260 },
16327 { 0x9B10A4E5E9913129, 827, 268 },
16328 { 0xE7109BFBA19C0C9D, 853, 276 },
16329 { 0xAC2820D9623BF429, 880, 284 },
16330 { 0x80444B5E7AA7CF85, 907, 292 },
16331 { 0xBF21E44003ACDD2D, 933, 300 },
16332 { 0x8E679C2F5E44FF8F, 960, 308 },
16333 { 0xD433179D9C8CB841, 986, 316 },
16334 { 0x9E19DB92B4E31BA9, 1013, 324 },
16344 const int f =
kAlpha - e - 1;
16345 const int k = (f * 78913) / (1 << 18) +
static_cast<int>(f > 0);
16347 const int index = (-kCachedPowersMinDecExp + k + (kCachedPowersDecStep - 1)) / kCachedPowersDecStep;
16349 JSON_ASSERT(
static_cast<std::size_t
>(index) < kCachedPowers.size());
16351 const cached_power cached = kCachedPowers[
static_cast<std::size_t
>(index)];
16365 if (n >= 1000000000)
16367 pow10 = 1000000000;
16371 if (n >= 100000000)
16416inline void grisu2_round(
char* buf,
int len, std::uint64_t dist, std::uint64_t delta,
16417 std::uint64_t rest, std::uint64_t ten_k)
16444 && delta - rest >= ten_k
16445 && (rest + ten_k < dist || dist - rest > rest + ten_k - dist))
16460 static_assert(
kAlpha >= -60,
"internal error");
16461 static_assert(
kGamma <= -32,
"internal error");
16478 std::uint64_t delta =
diyfp::sub(M_plus, M_minus).
f;
16488 const diyfp one(std::uint64_t{1} << -M_plus.
e, M_plus.
e);
16490 auto p1 =
static_cast<std::uint32_t
>(M_plus.
f >> -one.e);
16491 std::uint64_t p2 = M_plus.
f & (one.f - 1);
16499 std::uint32_t pow10{};
16527 const std::uint32_t d = p1 / pow10;
16528 const std::uint32_t r = p1 % pow10;
16534 buffer[length++] =
static_cast<char>(
'0' + d);
16553 const std::uint64_t rest = (std::uint64_t{p1} << -one.e) + p2;
16558 decimal_exponent += n;
16569 const std::uint64_t ten_n = std::uint64_t{pow10} << -one.e;
16570 grisu2_round(buffer, length, dist, delta, rest, ten_n);
16631 JSON_ASSERT(p2 <= (std::numeric_limits<std::uint64_t>::max)() / 10);
16633 const std::uint64_t d = p2 >> -one.e;
16634 const std::uint64_t r = p2 & (one.f - 1);
16641 buffer[length++] =
static_cast<char>(
'0' + d);
16666 decimal_exponent -= m;
16674 const std::uint64_t ten_m = one.f;
16698inline
void grisu2(
char* buf,
int& len,
int& decimal_exponent,
16715 const diyfp c_minus_k(cached.
f, cached.
e);
16743 const diyfp M_minus(w_minus.
f + 1, w_minus.
e);
16744 const diyfp M_plus (w_plus.
f - 1, w_plus.
e );
16746 decimal_exponent = -cached.
k;
16756template<
typename FloatType>
16758void
grisu2(
char* buf,
int& len,
int& decimal_exponent, FloatType value)
16761 "internal error: not enough precision");
16813 auto k =
static_cast<std::uint32_t
>(e);
16819 *buf++ =
static_cast<char>(
'0' + k);
16823 *buf++ =
static_cast<char>(
'0' + k / 10);
16825 *buf++ =
static_cast<char>(
'0' + k);
16829 *buf++ =
static_cast<char>(
'0' + k / 100);
16831 *buf++ =
static_cast<char>(
'0' + k / 10);
16833 *buf++ =
static_cast<char>(
'0' + k);
16851 int min_exp,
int max_exp)
16857 const int n = len + decimal_exponent;
16863 if (k <= n && n <= max_exp)
16868 std::memset(buf + k,
'0',
static_cast<size_t>(n) -
static_cast<size_t>(k));
16872 return buf + (
static_cast<size_t>(n) + 2);
16875 if (0 < n && n <= max_exp)
16882 std::memmove(buf + (
static_cast<size_t>(n) + 1), buf + n,
static_cast<size_t>(k) -
static_cast<size_t>(n));
16884 return buf + (
static_cast<size_t>(k) + 1U);
16887 if (min_exp < n && n <= 0)
16892 std::memmove(buf + (2 +
static_cast<size_t>(-n)), buf,
static_cast<size_t>(k));
16895 std::memset(buf + 2,
'0',
static_cast<size_t>(-n));
16896 return buf + (2U +
static_cast<size_t>(-n) +
static_cast<size_t>(k));
16911 std::memmove(buf + 2, buf + 1,
static_cast<size_t>(k) - 1);
16913 buf += 1 +
static_cast<size_t>(k);
16932template<
typename FloatType>
16935char*
to_chars(
char* first, const
char* last, FloatType value)
16937 static_cast<void>(last);
16941 if (std::signbit(
value))
16948#pragma GCC diagnostic push
16949#pragma GCC diagnostic ignored "-Wfloat-equal"
16960#pragma GCC diagnostic pop
16963 JSON_ASSERT(last - first >= std::numeric_limits<FloatType>::max_digits10);
16970 int decimal_exponent = 0;
16973 JSON_ASSERT(len <= std::numeric_limits<FloatType>::max_digits10);
16976 constexpr int kMinExp = -4;
16978 constexpr int kMaxExp = std::numeric_limits<FloatType>::digits10;
16981 JSON_ASSERT(last - first >= 2 + (-kMinExp - 1) + std::numeric_limits<FloatType>::max_digits10);
16982 JSON_ASSERT(last - first >= std::numeric_limits<FloatType>::max_digits10 + 6);
17021template<
typename BasicJsonType>
17024 using string_t =
typename BasicJsonType::string_t;
17025 using number_float_t =
typename BasicJsonType::number_float_t;
17026 using number_integer_t =
typename BasicJsonType::number_integer_t;
17027 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
17028 using binary_char_t =
typename BasicJsonType::binary_t::value_type;
17029 static constexpr std::uint8_t UTF8_ACCEPT = 0;
17030 static constexpr std::uint8_t UTF8_REJECT = 1;
17041 ,
loc(
std::localeconv())
17079 const bool pretty_print,
17081 const unsigned int indent_step,
17082 const unsigned int current_indent = 0)
17084 switch (val.m_type)
17088 if (val.m_value.object->empty())
17090 o->write_characters(
"{}", 2);
17096 o->write_characters(
"{\n", 2);
17099 const auto new_indent = current_indent + indent_step;
17106 auto i = val.m_value.object->cbegin();
17107 for (std::size_t cnt = 0; cnt < val.m_value.object->size() - 1; ++cnt, ++i)
17110 o->write_character(
'\"');
17112 o->write_characters(
"\": ", 3);
17114 o->write_characters(
",\n", 2);
17119 JSON_ASSERT(std::next(i) == val.m_value.object->cend());
17121 o->write_character(
'\"');
17123 o->write_characters(
"\": ", 3);
17126 o->write_character(
'\n');
17127 o->write_characters(
indent_string.c_str(), current_indent);
17128 o->write_character(
'}');
17132 o->write_character(
'{');
17135 auto i = val.m_value.object->cbegin();
17136 for (std::size_t cnt = 0; cnt < val.m_value.object->size() - 1; ++cnt, ++i)
17138 o->write_character(
'\"');
17140 o->write_characters(
"\":", 2);
17142 o->write_character(
',');
17147 JSON_ASSERT(std::next(i) == val.m_value.object->cend());
17148 o->write_character(
'\"');
17150 o->write_characters(
"\":", 2);
17153 o->write_character(
'}');
17161 if (val.m_value.array->empty())
17163 o->write_characters(
"[]", 2);
17169 o->write_characters(
"[\n", 2);
17172 const auto new_indent = current_indent + indent_step;
17179 for (
auto i = val.m_value.array->cbegin();
17180 i != val.m_value.array->cend() - 1; ++i)
17184 o->write_characters(
",\n", 2);
17190 dump(val.m_value.array->back(),
true,
ensure_ascii, indent_step, new_indent);
17192 o->write_character(
'\n');
17193 o->write_characters(
indent_string.c_str(), current_indent);
17194 o->write_character(
']');
17198 o->write_character(
'[');
17201 for (
auto i = val.m_value.array->cbegin();
17202 i != val.m_value.array->cend() - 1; ++i)
17205 o->write_character(
',');
17210 dump(val.m_value.array->back(),
false,
ensure_ascii, indent_step, current_indent);
17212 o->write_character(
']');
17220 o->write_character(
'\"');
17222 o->write_character(
'\"');
17230 o->write_characters(
"{\n", 2);
17233 const auto new_indent = current_indent + indent_step;
17241 o->write_characters(
"\"bytes\": [", 10);
17243 if (!val.m_value.binary->empty())
17245 for (
auto i = val.m_value.binary->cbegin();
17246 i != val.m_value.binary->cend() - 1; ++i)
17249 o->write_characters(
", ", 2);
17251 dump_integer(val.m_value.binary->back());
17254 o->write_characters(
"],\n", 3);
17257 o->write_characters(
"\"subtype\": ", 11);
17258 if (val.m_value.binary->has_subtype())
17260 dump_integer(val.m_value.binary->subtype());
17264 o->write_characters(
"null", 4);
17266 o->write_character(
'\n');
17267 o->write_characters(
indent_string.c_str(), current_indent);
17268 o->write_character(
'}');
17272 o->write_characters(
"{\"bytes\":[", 10);
17274 if (!val.m_value.binary->empty())
17276 for (
auto i = val.m_value.binary->cbegin();
17277 i != val.m_value.binary->cend() - 1; ++i)
17280 o->write_character(
',');
17282 dump_integer(val.m_value.binary->back());
17285 o->write_characters(
"],\"subtype\":", 12);
17286 if (val.m_value.binary->has_subtype())
17288 dump_integer(val.m_value.binary->subtype());
17289 o->write_character(
'}');
17293 o->write_characters(
"null}", 5);
17301 if (val.m_value.boolean)
17303 o->write_characters(
"true", 4);
17307 o->write_characters(
"false", 5);
17314 dump_integer(val.m_value.number_integer);
17320 dump_integer(val.m_value.number_unsigned);
17326 dump_float(val.m_value.number_float);
17332 o->write_characters(
"<discarded>", 11);
17338 o->write_characters(
"null", 4);
17364 std::uint32_t codepoint{};
17372 for (std::size_t i = 0; i < s.size(); ++i)
17374 const auto byte =
static_cast<std::uint8_t
>(s[i]);
17376 switch (decode(
state, codepoint,
byte))
17435 if ((codepoint <= 0x1F) || (
ensure_ascii && (codepoint >= 0x7F)))
17437 if (codepoint <= 0xFFFF)
17441 static_cast<std::uint16_t
>(codepoint)));
17447 static_cast<void>((std::snprintf)(
string_buffer.data() +
bytes, 13,
"\\u%04x\\u%04x",
17448 static_cast<std::uint16_t
>(0xD7C0u + (codepoint >> 10u)),
17449 static_cast<std::uint16_t
>(0xDC00u + (codepoint & 0x3FFu))));
17537 state = UTF8_ACCEPT;
17593 o->write_characters(
"\\ufffd", 6);
17597 o->write_characters(
"\xEF\xBF\xBD", 3);
17617 inline unsigned int count_digits(number_unsigned_t x)
noexcept
17619 unsigned int n_digits = 1;
17628 return n_digits + 1;
17632 return n_digits + 2;
17636 return n_digits + 3;
17648 static std::string hex_bytes(std::uint8_t
byte)
17650 std::string result =
"FF";
17651 constexpr const char* nibble_to_hex =
"0123456789ABCDEF";
17652 result[0] = nibble_to_hex[
byte / 16];
17653 result[1] = nibble_to_hex[
byte % 16];
17658 template <typename NumberType, enable_if_t<std::is_signed<NumberType>::value,
int> = 0>
17659 bool is_negative_number(NumberType x)
17664 template < typename NumberType, enable_if_t <std::is_unsigned<NumberType>::value,
int > = 0 >
17665 bool is_negative_number(NumberType )
17680 std::is_integral<NumberType>::value ||
17681 std::is_same<NumberType, number_unsigned_t>::value ||
17682 std::is_same<NumberType, number_integer_t>::value ||
17683 std::is_same<NumberType, binary_char_t>::value,
17685 void dump_integer(NumberType x)
17687 static constexpr std::array<std::array<char, 2>, 100> digits_to_99
17690 {{
'0',
'0'}}, {{
'0',
'1'}}, {{
'0',
'2'}}, {{
'0',
'3'}}, {{
'0',
'4'}}, {{
'0',
'5'}}, {{
'0',
'6'}}, {{
'0',
'7'}}, {{
'0',
'8'}}, {{
'0',
'9'}},
17691 {{
'1',
'0'}}, {{
'1',
'1'}}, {{
'1',
'2'}}, {{
'1',
'3'}}, {{
'1',
'4'}}, {{
'1',
'5'}}, {{
'1',
'6'}}, {{
'1',
'7'}}, {{
'1',
'8'}}, {{
'1',
'9'}},
17692 {{
'2',
'0'}}, {{
'2',
'1'}}, {{
'2',
'2'}}, {{
'2',
'3'}}, {{
'2',
'4'}}, {{
'2',
'5'}}, {{
'2',
'6'}}, {{
'2',
'7'}}, {{
'2',
'8'}}, {{
'2',
'9'}},
17693 {{
'3',
'0'}}, {{
'3',
'1'}}, {{
'3',
'2'}}, {{
'3',
'3'}}, {{
'3',
'4'}}, {{
'3',
'5'}}, {{
'3',
'6'}}, {{
'3',
'7'}}, {{
'3',
'8'}}, {{
'3',
'9'}},
17694 {{
'4',
'0'}}, {{
'4',
'1'}}, {{
'4',
'2'}}, {{
'4',
'3'}}, {{
'4',
'4'}}, {{
'4',
'5'}}, {{
'4',
'6'}}, {{
'4',
'7'}}, {{
'4',
'8'}}, {{
'4',
'9'}},
17695 {{
'5',
'0'}}, {{
'5',
'1'}}, {{
'5',
'2'}}, {{
'5',
'3'}}, {{
'5',
'4'}}, {{
'5',
'5'}}, {{
'5',
'6'}}, {{
'5',
'7'}}, {{
'5',
'8'}}, {{
'5',
'9'}},
17696 {{
'6',
'0'}}, {{
'6',
'1'}}, {{
'6',
'2'}}, {{
'6',
'3'}}, {{
'6',
'4'}}, {{
'6',
'5'}}, {{
'6',
'6'}}, {{
'6',
'7'}}, {{
'6',
'8'}}, {{
'6',
'9'}},
17697 {{
'7',
'0'}}, {{
'7',
'1'}}, {{
'7',
'2'}}, {{
'7',
'3'}}, {{
'7',
'4'}}, {{
'7',
'5'}}, {{
'7',
'6'}}, {{
'7',
'7'}}, {{
'7',
'8'}}, {{
'7',
'9'}},
17698 {{
'8',
'0'}}, {{
'8',
'1'}}, {{
'8',
'2'}}, {{
'8',
'3'}}, {{
'8',
'4'}}, {{
'8',
'5'}}, {{
'8',
'6'}}, {{
'8',
'7'}}, {{
'8',
'8'}}, {{
'8',
'9'}},
17699 {{
'9',
'0'}}, {{
'9',
'1'}}, {{
'9',
'2'}}, {{
'9',
'3'}}, {{
'9',
'4'}}, {{
'9',
'5'}}, {{
'9',
'6'}}, {{
'9',
'7'}}, {{
'9',
'8'}}, {{
'9',
'9'}},
17706 o->write_character(
'0');
17713 number_unsigned_t abs_value;
17715 unsigned int n_chars{};
17717 if (is_negative_number(x))
17720 abs_value = remove_sign(
static_cast<number_integer_t
>(x));
17723 n_chars = 1 + count_digits(abs_value);
17727 abs_value =
static_cast<number_unsigned_t
>(x);
17728 n_chars = count_digits(abs_value);
17736 buffer_ptr += n_chars;
17740 while (abs_value >= 100)
17742 const auto digits_index =
static_cast<unsigned>((abs_value % 100));
17744 *(--buffer_ptr) = digits_to_99[digits_index][1];
17745 *(--buffer_ptr) = digits_to_99[digits_index][0];
17748 if (abs_value >= 10)
17750 const auto digits_index =
static_cast<unsigned>(abs_value);
17751 *(--buffer_ptr) = digits_to_99[digits_index][1];
17752 *(--buffer_ptr) = digits_to_99[digits_index][0];
17756 *(--buffer_ptr) =
static_cast<char>(
'0' + abs_value);
17770 void dump_float(number_float_t x)
17773 if (!std::isfinite(x))
17775 o->write_characters(
"null", 4);
17784 static constexpr bool is_ieee_single_or_double
17785 = (std::numeric_limits<number_float_t>::is_iec559 && std::numeric_limits<number_float_t>::digits == 24 && std::numeric_limits<number_float_t>::max_exponent == 128) ||
17786 (std::numeric_limits<number_float_t>::is_iec559 && std::numeric_limits<number_float_t>::digits == 53 && std::numeric_limits<number_float_t>::max_exponent == 1024);
17788 dump_float(x, std::integral_constant<bool, is_ieee_single_or_double>());
17791 void dump_float(number_float_t x, std::true_type )
17796 o->write_characters(begin,
static_cast<size_t>(end - begin));
17799 void dump_float(number_float_t x, std::false_type )
17802 static constexpr auto d = std::numeric_limits<number_float_t>::max_digits10;
17834 o->write_characters(
number_buffer.data(),
static_cast<std::size_t
>(len));
17837 const bool value_is_int_like =
17841 return c ==
'.' || c ==
'e';
17844 if (value_is_int_like)
17846 o->write_characters(
".0", 2);
17871 static std::uint8_t decode(std::uint8_t&
state, std::uint32_t& codep,
const std::uint8_t
byte)
noexcept
17873 static const std::array<std::uint8_t, 400> utf8d =
17876 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
17877 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
17878 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
17879 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
17880 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
17881 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
17882 8, 8, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
17883 0xA, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x4, 0x3, 0x3,
17884 0xB, 0x6, 0x6, 0x6, 0x5, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8,
17885 0x0, 0x1, 0x2, 0x3, 0x5, 0x8, 0x7, 0x1, 0x1, 0x1, 0x4, 0x6, 0x1, 0x1, 0x1, 0x1,
17886 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1,
17887 1, 2, 1, 1, 1, 1, 1, 2, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1,
17888 1, 2, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 3, 1, 1, 1, 1, 1, 1,
17889 1, 3, 1, 1, 1, 1, 1, 3, 1, 3, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
17894 const std::uint8_t type = utf8d[byte];
17896 codep = (
state != UTF8_ACCEPT)
17897 ? (
byte & 0x3fu) | (codep << 6u)
17898 : (0xFFu >> type) & (byte);
17900 std::size_t index = 256u +
static_cast<size_t>(
state) * 16u +
static_cast<size_t>(type);
17902 state = utf8d[index];
17911 number_unsigned_t remove_sign(number_unsigned_t x)
17926 inline number_unsigned_t remove_sign(number_integer_t x)
noexcept
17928 JSON_ASSERT(x < 0 && x < (std::numeric_limits<number_integer_t>::max)());
17929 return static_cast<number_unsigned_t
>(-(x + 1)) + 1;
17934 output_adapter_t<char> o =
nullptr;
17967#include <functional>
17968#include <initializer_list>
17971#include <stdexcept>
17972#include <type_traits>
17984template <
class Key,
class T,
class IgnoredLess = std::less<Key>,
17985 class Allocator = std::allocator<std::pair<const Key, T>>>
17990 using Container = std::vector<std::pair<const Key, T>, Allocator>;
17995#ifdef JSON_HAS_CPP_14
18005 template <
class It>
18008 ordered_map(std::initializer_list<value_type> init,
const Allocator& alloc = Allocator() )
18013 for (
auto it = this->begin(); it != this->end(); ++it)
18015 if (m_compare(it->first, key))
18017 return {it,
false};
18020 Container::emplace_back(key, t);
18021 return {--this->end(),
true};
18026 return emplace(key, T{}).first->second;
18036 for (
auto it = this->begin(); it != this->end(); ++it)
18038 if (m_compare(it->first, key))
18044 JSON_THROW(std::out_of_range(
"key not found"));
18047 const T&
at(
const Key& key)
const
18049 for (
auto it = this->begin(); it != this->end(); ++it)
18051 if (m_compare(it->first, key))
18057 JSON_THROW(std::out_of_range(
"key not found"));
18062 for (
auto it = this->begin(); it != this->end(); ++it)
18064 if (m_compare(it->first, key))
18067 for (
auto next = it; ++next != this->end(); ++it)
18072 Container::pop_back();
18081 return erase(pos, std::next(pos));
18086 const auto elements_affected = std::distance(first, last);
18087 const auto offset = std::distance(Container::begin(), first);
18109 for (
auto it = first; std::next(it, elements_affected) != Container::end(); ++it)
18112 new (&*it)
value_type{std::move(*std::next(it, elements_affected))};
18120 Container::resize(this->size() -
static_cast<size_type>(elements_affected));
18129 return Container::begin() + offset;
18134 for (
auto it = this->begin(); it != this->end(); ++it)
18136 if (m_compare(it->first, key))
18146 for (
auto it = this->begin(); it != this->end(); ++it)
18148 if (m_compare(it->first, key))
18153 return Container::end();
18158 for (
auto it = this->begin(); it != this->end(); ++it)
18160 if (m_compare(it->first, key))
18165 return Container::end();
18170 return emplace(value.first, std::move(value.second));
18175 for (
auto it = this->begin(); it != this->end(); ++it)
18177 if (m_compare(it->first, value.first))
18179 return {it,
false};
18182 Container::push_back(value);
18183 return {--this->end(),
true};
18186 template<
typename InputIt>
18187 using require_input_iter =
typename std::enable_if<std::is_convertible<typename std::iterator_traits<InputIt>::iterator_category,
18188 std::input_iterator_tag>::value>::type;
18190 template<
typename InputIt,
typename = require_input_iter<InputIt>>
18193 for (
auto it = first; it != last; ++it)
18206#if defined(JSON_HAS_CPP_17)
18208 #include <string_view>
18244 friend class ::nlohmann::json_pointer;
18248 template<
typename BasicJsonType,
typename InputType>
18249 friend class ::nlohmann::detail::parser;
18250 friend ::nlohmann::detail::serializer<basic_json>;
18251 template<
typename BasicJsonType>
18252 friend class ::nlohmann::detail::iter_impl;
18253 template<
typename BasicJsonType,
typename CharType>
18254 friend class ::nlohmann::detail::binary_writer;
18255 template<
typename BasicJsonType,
typename InputType,
typename SAX>
18256 friend class ::nlohmann::detail::binary_reader;
18257 template<
typename BasicJsonType>
18258 friend class ::nlohmann::detail::json_sax_dom_parser;
18259 template<
typename BasicJsonType>
18260 friend class ::nlohmann::detail::json_sax_dom_callback_parser;
18261 friend class ::nlohmann::detail::exception;
18270 template<
typename InputAdapterType>
18271 static ::nlohmann::detail::parser<basic_json, InputAdapterType> parser(
18272 InputAdapterType adapter,
18274 const bool allow_exceptions =
true,
18275 const bool ignore_comments =
false
18278 return ::nlohmann::detail::parser<basic_json, InputAdapterType>(std::move(adapter),
18279 std::move(cb), allow_exceptions, ignore_comments);
18284 template<
typename BasicJsonType>
18286 template<
typename BasicJsonType>
18288 template<
typename Iterator>
18292 template<
typename CharType>
18295 template<
typename InputType>
18306 template<
typename T,
typename SFINAE>
18363 using pointer =
typename std::allocator_traits<allocator_type>::pointer;
18365 using const_pointer =
typename std::allocator_traits<allocator_type>::const_pointer;
18393 result[
"copyright"] =
"(C) 2013-2022 Niels Lohmann";
18394 result[
"name"] =
"JSON for Modern C++";
18395 result[
"url"] =
"https://github.com/nlohmann/json";
18396 result[
"version"][
"string"] =
18405 result[
"platform"] =
"win32";
18406#elif defined __linux__
18407 result[
"platform"] =
"linux";
18408#elif defined __APPLE__
18409 result[
"platform"] =
"apple";
18410#elif defined __unix__
18411 result[
"platform"] =
"unix";
18413 result[
"platform"] =
"unknown";
18416#if defined(__ICC) || defined(__INTEL_COMPILER)
18417 result[
"compiler"] = {{
"family",
"icc"}, {
"version", __INTEL_COMPILER}};
18418#elif defined(__clang__)
18419 result[
"compiler"] = {{
"family",
"clang"}, {
"version", __clang_version__}};
18420#elif defined(__GNUC__) || defined(__GNUG__)
18421 result[
"compiler"] = {{
"family",
"gcc"}, {
"version",
detail::concat(
18427#elif defined(__HP_cc) || defined(__HP_aCC)
18428 result[
"compiler"] =
"hp"
18429#elif defined(__IBMCPP__)
18430 result[
"compiler"] = {{
"family",
"ilecpp"}, {
"version", __IBMCPP__}};
18431#elif defined(_MSC_VER)
18432 result[
"compiler"] = {{
"family",
"msvc"}, {
"version", _MSC_VER}};
18433#elif defined(__PGI)
18434 result[
"compiler"] = {{
"family",
"pgcpp"}, {
"version", __PGI}};
18435#elif defined(__SUNPRO_CC)
18436 result[
"compiler"] = {{
"family",
"sunpro"}, {
"version", __SUNPRO_CC}};
18438 result[
"compiler"] = {{
"family",
"unknown"}, {
"version",
"unknown"}};
18442#if defined(_MSVC_LANG)
18444#elif defined(__cplusplus)
18447 result[
"compiler"][
"c++"] =
"unknown";
18466#if defined(JSON_HAS_CPP_14)
18479 AllocatorType<std::pair<
const StringType,
18484 using array_t = ArrayType<basic_json, AllocatorType<basic_json>>;
18519 template<
typename T,
typename... Args>
18521 static T* create(Args&& ... args)
18523 AllocatorType<T> alloc;
18524 using AllocatorTraits = std::allocator_traits<AllocatorType<T>>;
18526 auto deleter = [&](T * obj)
18528 AllocatorTraits::deallocate(alloc, obj, 1);
18530 std::unique_ptr<T,
decltype(deleter)> obj(AllocatorTraits::allocate(alloc, 1), deleter);
18531 AllocatorTraits::construct(alloc, obj.get(), std::forward<Args>(args)...);
18533 return obj.release();
18586 json_value() =
default;
18588 json_value(
boolean_t v) noexcept : boolean(v) {}
18602 object = create<object_t>();
18608 array = create<array_t>();
18614 string = create<string_t>(
"");
18620 binary = create<binary_t>();
18626 boolean =
static_cast<boolean_t>(
false);
18702 std::vector<basic_json> stack;
18707 stack.reserve(
array->size());
18708 std::move(
array->begin(),
array->end(), std::back_inserter(stack));
18712 stack.reserve(
object->size());
18713 for (
auto&& it : *
object)
18715 stack.push_back(std::move(it.second));
18719 while (!stack.empty())
18722 basic_json current_item(std::move(stack.back()));
18727 if (current_item.is_array())
18729 std::move(current_item.m_value.array->begin(), current_item.m_value.array->end(), std::back_inserter(stack));
18731 current_item.m_value.array->clear();
18733 else if (current_item.is_object())
18735 for (
auto&& it : *current_item.m_value.object)
18737 stack.push_back(std::move(it.second));
18740 current_item.m_value.object->clear();
18752 AllocatorType<object_t> alloc;
18753 std::allocator_traits<
decltype(alloc)>::destroy(alloc,
object);
18754 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
object, 1);
18760 AllocatorType<array_t> alloc;
18761 std::allocator_traits<
decltype(alloc)>::destroy(alloc, array);
18762 std::allocator_traits<
decltype(alloc)>::deallocate(alloc, array, 1);
18768 AllocatorType<string_t> alloc;
18769 std::allocator_traits<
decltype(alloc)>::destroy(alloc,
string);
18770 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
string, 1);
18776 AllocatorType<binary_t> alloc;
18777 std::allocator_traits<
decltype(alloc)>::destroy(alloc, binary);
18778 std::allocator_traits<
decltype(alloc)>::deallocate(alloc, binary, 1);
18815 void assert_invariant(
bool check_parents =
true) const noexcept
18822#if JSON_DIAGNOSTICS
18828 return j.m_parent ==
this;
18833 static_cast<void>(check_parents);
18838#if JSON_DIAGNOSTICS
18843 for (
auto& element : *
m_value.array)
18845 element.m_parent =
this;
18852 for (
auto& element : *
m_value.object)
18854 element.second.m_parent =
this;
18875#if JSON_DIAGNOSTICS
18878 (it + i)->m_parent =
this;
18881 static_cast<void>(count_set_parents);
18886 reference set_parent(
reference j, std::size_t old_capacity =
static_cast<std::size_t
>(-1))
18888#if JSON_DIAGNOSTICS
18889 if (old_capacity !=
static_cast<std::size_t
>(-1))
18903#ifdef JSON_HEDLEY_MSVC_VERSION
18904#pragma warning(push )
18905#pragma warning(disable : 4127)
18912#ifdef JSON_HEDLEY_MSVC_VERSION
18913#pragma warning( pop )
18918 static_cast<void>(j);
18919 static_cast<void>(old_capacity);
18951 assert_invariant();
18959 assert_invariant();
18964 template <
typename CompatibleType,
18970 std::forward<CompatibleType>(val))))
18974 assert_invariant();
18979 template <
typename BasicJsonType,
18984 using other_boolean_t =
typename BasicJsonType::boolean_t;
18985 using other_number_float_t =
typename BasicJsonType::number_float_t;
18986 using other_number_integer_t =
typename BasicJsonType::number_integer_t;
18987 using other_number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
18988 using other_string_t =
typename BasicJsonType::string_t;
18989 using other_object_t =
typename BasicJsonType::object_t;
18990 using other_array_t =
typename BasicJsonType::array_t;
18991 using other_binary_t =
typename BasicJsonType::binary_t;
18993 switch (val.type())
19029 assert_invariant();
19035 bool type_deduction =
true,
19040 bool is_an_object = std::all_of(init.begin(), init.end(),
19043 return element_ref->is_array() && element_ref->size() == 2 && (*element_ref)[0].is_string();
19047 if (!type_deduction)
19052 is_an_object =
false;
19068 for (
auto& element_ref : init)
19072 std::move(*((*element.m_value.array)[0].m_value.string)),
19073 std::move((*element.m_value.array)[1]));
19080 m_value.array = create<array_t>(init.begin(), init.end());
19084 assert_invariant();
19094 res.m_value = init;
19105 res.m_value =
binary_t(init, subtype);
19116 res.m_value = std::move(init);
19127 res.m_value =
binary_t(std::move(init), subtype);
19152 m_value.array = create<array_t>(cnt, val);
19154 assert_invariant();
19159 template <
class InputIT,
typename std::enable_if <
19160 std::is_same<InputIT, typename basic_json_t::iterator>::value ||
19161 std::is_same<InputIT, typename basic_json_t::const_iterator>::value,
int >
::type = 0 >
19174 m_type = first.m_object->m_type;
19186 || !last.m_it.primitive_iterator.is_end()))
19206 m_value.number_integer = first.m_object->m_value.number_integer;
19212 m_value.number_unsigned = first.m_object->m_value.number_unsigned;
19218 m_value.number_float = first.m_object->m_value.number_float;
19224 m_value.boolean = first.m_object->m_value.boolean;
19230 m_value = *first.m_object->m_value.string;
19236 m_value.object = create<object_t>(first.m_it.object_iterator,
19237 last.m_it.object_iterator);
19243 m_value.array = create<array_t>(first.m_it.array_iterator,
19244 last.m_it.array_iterator);
19250 m_value = *first.m_object->m_value.binary;
19261 assert_invariant();
19269 template<
typename JsonRef,
19271 std::is_same<typename JsonRef::value_type, basic_json>>
::value,
int> = 0 >
19277 : m_type(other.m_type)
19280 other.assert_invariant();
19339 assert_invariant();
19345 : m_type(std::move(other.m_type)),
19346 m_value(std::move(other.m_value))
19349 other.assert_invariant(
false);
19353 other.m_value = {};
19356 assert_invariant();
19362 std::is_nothrow_move_constructible<value_t>::value&&
19363 std::is_nothrow_move_assignable<value_t>::value&&
19364 std::is_nothrow_move_constructible<json_value>::value&&
19365 std::is_nothrow_move_assignable<json_value>::value
19369 other.assert_invariant();
19372 swap(m_type, other.m_type);
19376 assert_invariant();
19384 assert_invariant(
false);
19402 const char indent_char =
' ',
19403 const bool ensure_ascii =
false,
19411 s.dump(*
this,
true, ensure_ascii,
static_cast<unsigned int>(indent));
19415 s.dump(*
this,
false, ensure_ascii, 0);
19563 constexpr const array_t* get_impl_ptr(
const array_t* )
const noexcept
19651 template<
typename ReferenceType,
typename ThisType>
19652 static ReferenceType get_ref_impl(ThisType& obj)
19655 auto* ptr = obj.template get_ptr<typename std::add_pointer<ReferenceType>::type>();
19672 template<
typename PointerType,
typename std::enable_if<
19673 std::is_pointer<PointerType>::value,
int>
::type = 0>
19674 auto get_ptr() noexcept -> decltype(
std::declval<basic_json_t&>().get_impl_ptr(
std::declval<PointerType>()))
19677 return get_impl_ptr(
static_cast<PointerType
>(
nullptr));
19682 template <
typename PointerType,
typename std::enable_if <
19683 std::is_pointer<PointerType>::value&&
19684 std::is_const<typename std::remove_pointer<PointerType>::type>
::value,
int >
::type = 0 >
19685 constexpr auto get_ptr() const noexcept -> decltype(
std::declval<const basic_json_t&>().get_impl_ptr(
std::declval<PointerType>()))
19688 return get_impl_ptr(
static_cast<PointerType
>(
nullptr));
19730 template <
typename ValueType,
19738 auto ret = ValueType();
19773 template <
typename ValueType,
19775 detail::has_non_default_from_json<basic_json_t, ValueType>::value,
19777 ValueType get_impl(detail::priority_tag<1> )
const noexcept(
noexcept(
19798 template <
typename BasicJsonType,
19800 detail::is_basic_json<BasicJsonType>::value,
19802 BasicJsonType get_impl(detail::priority_tag<2> )
const
19821 template<
typename BasicJsonType,
19823 std::is_same<BasicJsonType, basic_json_t>::value,
19825 basic_json get_impl(detail::priority_tag<3> )
const
19834 template<
typename PointerType,
19836 std::is_pointer<PointerType>::value,
19838 constexpr auto get_impl(detail::priority_tag<4> )
const noexcept
19839 ->
decltype(std::declval<const basic_json_t&>().template get_ptr<PointerType>())
19842 return get_ptr<PointerType>();
19869 template <
typename ValueTypeCV,
typename ValueType = detail::uncvref_t<ValueTypeCV>>
19870#if defined(JSON_HAS_CPP_14)
19874 noexcept(
std::declval<const basic_json_t&>().template get_impl<ValueType>(detail::priority_tag<4> {})))
19880 static_assert(!std::is_reference<ValueTypeCV>::value,
19881 "get() cannot be used with reference types, you might want to use get_ref()");
19882 return get_impl<ValueType>(detail::priority_tag<4> {});
19912 template<
typename PointerType,
typename std::enable_if<
19913 std::is_pointer<PointerType>::value,
int>
::type = 0>
19914 auto get() noexcept -> decltype(
std::declval<basic_json_t&>().template
get_ptr<PointerType>())
19917 return get_ptr<PointerType>();
19922 template <
typename ValueType,
19927 ValueType &
get_to(ValueType& v)
const noexcept(
noexcept(
19936 template<
typename ValueType,
19947 typename T, std::size_t N,
19948 typename Array = T (&)[N],
19953 std::declval<const basic_json_t&>(), v)))
19961 template<
typename ReferenceType,
typename std::enable_if<
19962 std::is_reference<ReferenceType>::value,
int>
::type = 0>
19966 return get_ref_impl<ReferenceType>(*
this);
19971 template <
typename ReferenceType,
typename std::enable_if <
19972 std::is_reference<ReferenceType>::value&&
19973 std::is_const<typename std::remove_reference<ReferenceType>::type>
::value,
int >
::type = 0 >
19977 return get_ref_impl<ReferenceType>(*
this);
20009 template <
typename ValueType,
typename std::enable_if <
20018#if defined(JSON_HAS_CPP_17) && (defined(__GNUC__) || (defined(_MSC_VER) && _MSC_VER >= 1910 && _MSC_VER <= 1914))
20021#if defined(JSON_HAS_CPP_17)
20029 return get<ValueType>();
20041 return *get_ptr<binary_t*>();
20053 return *get_ptr<const binary_t*>();
20076 return set_parent(
m_value.array->at(idx));
20099 return m_value.array->at(idx);
20123 auto it =
m_value.object->find(key);
20124 if (it ==
m_value.object->end())
20128 return set_parent(it->second);
20143 auto it =
m_value.object->find(std::forward<KeyType>(key));
20144 if (it ==
m_value.object->end())
20148 return set_parent(it->second);
20161 auto it =
m_value.object->find(key);
20162 if (it ==
m_value.object->end())
20181 auto it =
m_value.object->find(std::forward<KeyType>(key));
20182 if (it ==
m_value.object->end())
20197 m_value.array = create<array_t>();
20198 assert_invariant();
20205 if (idx >=
m_value.array->size())
20207#if JSON_DIAGNOSTICS
20209 const auto old_size =
m_value.array->size();
20210 const auto old_capacity =
m_value.array->capacity();
20212 m_value.array->resize(idx + 1);
20214#if JSON_DIAGNOSTICS
20226 assert_invariant();
20229 return m_value.array->operator[](idx);
20242 return m_value.array->operator[](idx);
20256 m_value.object = create<object_t>();
20257 assert_invariant();
20263 auto result =
m_value.object->emplace(std::move(key),
nullptr);
20264 return set_parent(result.first->second);
20277 auto it =
m_value.object->find(key);
20287 template<
typename T>
20290 return operator[](
typename object_t::key_type(key));
20293 template<
typename T>
20296 return operator[](
typename object_t::key_type(key));
20309 m_value.object = create<object_t>();
20310 assert_invariant();
20316 auto result =
m_value.object->emplace(std::forward<KeyType>(key),
nullptr);
20317 return set_parent(result.first->second);
20332 auto it =
m_value.object->find(std::forward<KeyType>(key));
20344 std::is_same<KeyType, typename object_t::key_type>::value
20346 && !std::is_same<value_t, ValueType>::value,
int > = 0 >
20347 typename std::decay<ValueType>::type
value(
const KeyType& key, ValueType && default_value)
const
20353 const auto it =
find(key);
20356 return it->template get<typename std::decay<ValueType>::type>();
20359 return std::forward<ValueType>(default_value);
20368 string_t value(
const typename object_t::key_type& key,
const char* default_value)
const
20378 && !std::is_same<value_t, ValueType>::value,
int > = 0 >
20379 typename std::decay<ValueType>::type
value(
const char* key, ValueType && default_value)
const
20381 return value(
typename object_t::key_type(key), std::forward<ValueType>(default_value));
20386 return value(
typename object_t::key_type(key),
string_t(default_value));
20394 && !std::is_same<value_t, ValueType>::value
20396 typename std::decay<ValueType>::type
value(KeyType && key, ValueType && default_value)
const
20402 const auto it =
find(std::forward<KeyType>(key));
20405 return it->template get<typename std::decay<ValueType>::type>();
20408 return std::forward<ValueType>(default_value);
20421 return value(std::forward<KeyType>(key),
string_t(default_value));
20436 return ptr.get_checked(
this).template get<ValueType>();
20440 return default_value;
20450 ValueType
value(const ::nlohmann::json_pointer<BasicJsonType>& ptr,
const ValueType& default_value)
const
20452 return value(ptr.convert(), default_value);
20464 template<
typename BasicJsonType>
20469 return value(ptr.convert(), default_value);
20507 std::is_same<IteratorType, typename basic_json_t::iterator>::value ||
20508 std::is_same<IteratorType, typename basic_json_t::const_iterator>::value,
int > = 0 >
20517 IteratorType result = end();
20535 AllocatorType<string_t> alloc;
20536 std::allocator_traits<
decltype(alloc)>::destroy(alloc,
m_value.string);
20537 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
m_value.string, 1);
20542 AllocatorType<binary_t> alloc;
20543 std::allocator_traits<
decltype(alloc)>::destroy(alloc,
m_value.binary);
20544 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
m_value.binary, 1);
20549 assert_invariant();
20555 result.m_it.object_iterator =
m_value.object->erase(pos.m_it.object_iterator);
20561 result.m_it.array_iterator =
m_value.array->erase(pos.m_it.array_iterator);
20577 std::is_same<IteratorType, typename basic_json_t::iterator>::value ||
20578 std::is_same<IteratorType, typename basic_json_t::const_iterator>::value,
int > = 0 >
20579 IteratorType
erase(IteratorType first, IteratorType last)
20587 IteratorType result = end();
20599 || !last.m_it.primitive_iterator.is_end()))
20606 AllocatorType<string_t> alloc;
20607 std::allocator_traits<
decltype(alloc)>::destroy(alloc,
m_value.string);
20608 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
m_value.string, 1);
20613 AllocatorType<binary_t> alloc;
20614 std::allocator_traits<
decltype(alloc)>::destroy(alloc,
m_value.binary);
20615 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
m_value.binary, 1);
20620 assert_invariant();
20626 result.m_it.object_iterator =
m_value.object->erase(first.m_it.object_iterator,
20627 last.m_it.object_iterator);
20633 result.m_it.array_iterator =
m_value.array->erase(first.m_it.array_iterator,
20634 last.m_it.array_iterator);
20650 size_type erase_internal(KeyType && key)
20658 return m_value.object->erase(std::forward<KeyType>(key));
20662 !detail::has_erase_with_key_type<basic_json_t, KeyType>::value,
int > = 0 >
20663 size_type erase_internal(KeyType && key)
20671 const auto it =
m_value.object->find(std::forward<KeyType>(key));
20672 if (it !=
m_value.object->end())
20688 return erase_internal(key);
20697 return erase_internal(std::forward<KeyType>(key));
20734 auto result = end();
20738 result.m_it.object_iterator =
m_value.object->find(key);
20748 auto result = cend();
20752 result.m_it.object_iterator =
m_value.object->find(key);
20764 auto result = end();
20768 result.m_it.object_iterator =
m_value.object->find(std::forward<KeyType>(key));
20780 auto result = cend();
20784 result.m_it.object_iterator =
m_value.object->find(std::forward<KeyType>(key));
20805 return is_object() ?
m_value.object->count(std::forward<KeyType>(key)) : 0;
20810 bool contains(
const typename object_t::key_type& key)
const
20828 return ptr.contains(
this);
20831 template<
typename BasicJsonType>
20833 bool contains(
const typename ::nlohmann::json_pointer<BasicJsonType> ptr)
const
20835 return ptr.contains(
this);
20853 result.set_begin();
20869 result.set_begin();
20949 return ref.items();
20960 return ref.items();
20965 iteration_proxy<iterator> items() noexcept
20967 return iteration_proxy<iterator>(*
this);
20972 iteration_proxy<const_iterator> items() const noexcept
20974 return iteration_proxy<const_iterator>(*
this);
20989 bool empty() const noexcept
21002 return m_value.array->empty();
21008 return m_value.object->empty();
21041 return m_value.array->size();
21047 return m_value.object->size();
21074 return m_value.array->max_size();
21080 return m_value.object->max_size();
21111 void clear() noexcept
21185 assert_invariant();
21189 const auto old_capacity =
m_value.array->capacity();
21190 m_value.array->push_back(std::move(val));
21191 set_parent(
m_value.array->back(), old_capacity);
21218 assert_invariant();
21222 const auto old_capacity =
m_value.array->capacity();
21223 m_value.array->push_back(val);
21224 set_parent(
m_value.array->back(), old_capacity);
21250 assert_invariant();
21254 auto res =
m_value.object->insert(val);
21255 set_parent(res.first->second);
21270 if (
is_object() && init.size() == 2 && (*init.begin())->is_string())
21272 basic_json&& key = init.begin()->moved_or_copied();
21273 push_back(
typename object_t::value_type(
21274 std::move(key.get_ref<
string_t&>()), (init.begin() + 1)->moved_or_copied()));
21292 template<
class... Args>
21306 assert_invariant();
21310 const auto old_capacity =
m_value.array->capacity();
21311 m_value.array->emplace_back(std::forward<Args>(args)...);
21312 return set_parent(
m_value.array->back(), old_capacity);
21317 template<
class... Args>
21331 assert_invariant();
21335 auto res =
m_value.object->emplace(std::forward<Args>(args)...);
21336 set_parent(res.first->second);
21340 it.m_it.object_iterator = res.first;
21343 return {it, res.second};
21349 template<
typename... Args>
21391 return insert(pos, val);
21494 update(j.begin(), j.end(), merge_objects);
21505 m_value.object = create<object_t>();
21506 assert_invariant();
21526 for (
auto it = first; it != last; ++it)
21528 if (merge_objects && it.value().is_object())
21530 auto it2 =
m_value.object->find(it.key());
21531 if (it2 !=
m_value.object->end())
21533 it2->second.update(it.value(),
true);
21537 m_value.object->operator[](it.key()) = it.value();
21538#if JSON_DIAGNOSTICS
21539 m_value.object->operator[](it.key()).m_parent =
this;
21547 std::is_nothrow_move_constructible<value_t>::value&&
21548 std::is_nothrow_move_assignable<value_t>::value&&
21549 std::is_nothrow_move_constructible<json_value>::value&&
21550 std::is_nothrow_move_assignable<json_value>::value
21557 other.set_parents();
21558 assert_invariant();
21564 std::is_nothrow_move_constructible<value_t>::value&&
21565 std::is_nothrow_move_assignable<value_t>::value&&
21566 std::is_nothrow_move_constructible<json_value>::value&&
21567 std::is_nothrow_move_assignable<json_value>::value
21663#pragma GCC diagnostic push
21664#pragma GCC diagnostic ignored "-Wfloat-equal"
21666 const auto lhs_type = lhs.type();
21667 const auto rhs_type = rhs.type();
21669 if (lhs_type == rhs_type)
21674 return *lhs.m_value.array == *rhs.m_value.array;
21677 return *lhs.m_value.object == *rhs.m_value.object;
21683 return *lhs.m_value.string == *rhs.m_value.string;
21686 return lhs.m_value.boolean == rhs.m_value.boolean;
21689 return lhs.m_value.number_integer == rhs.m_value.number_integer;
21692 return lhs.m_value.number_unsigned == rhs.m_value.number_unsigned;
21695 return lhs.m_value.number_float == rhs.m_value.number_float;
21698 return *lhs.m_value.binary == *rhs.m_value.binary;
21707 return static_cast<number_float_t>(lhs.m_value.number_integer) == rhs.m_value.number_float;
21711 return lhs.m_value.number_float ==
static_cast<number_float_t>(rhs.m_value.number_integer);
21715 return static_cast<number_float_t>(lhs.m_value.number_unsigned) == rhs.m_value.number_float;
21719 return lhs.m_value.number_float ==
static_cast<number_float_t>(rhs.m_value.number_unsigned);
21723 return static_cast<number_integer_t>(lhs.m_value.number_unsigned) == rhs.m_value.number_integer;
21727 return lhs.m_value.number_integer ==
static_cast<number_integer_t>(rhs.m_value.number_unsigned);
21732#pragma GCC diagnostic pop
21738 template<
typename ScalarType,
typename std::enable_if<
21739 std::is_scalar<ScalarType>::value,
int>
::type = 0>
21747 template<
typename ScalarType,
typename std::enable_if<
21748 std::is_scalar<ScalarType>::value,
int>
::type = 0>
21758 return !(lhs == rhs);
21763 template<
typename ScalarType,
typename std::enable_if<
21764 std::is_scalar<ScalarType>::value,
int>
::type = 0>
21772 template<
typename ScalarType,
typename std::enable_if<
21773 std::is_scalar<ScalarType>::value,
int>
::type = 0>
21783 const auto lhs_type = lhs.type();
21784 const auto rhs_type = rhs.type();
21786 if (lhs_type == rhs_type)
21793 return (*lhs.m_value.array) < (*rhs.m_value.array);
21796 return (*lhs.m_value.object) < (*rhs.m_value.object);
21802 return (*lhs.m_value.string) < (*rhs.m_value.string);
21805 return (lhs.m_value.boolean) < (rhs.m_value.boolean);
21808 return (lhs.m_value.number_integer) < (rhs.m_value.number_integer);
21811 return (lhs.m_value.number_unsigned) < (rhs.m_value.number_unsigned);
21814 return (lhs.m_value.number_float) < (rhs.m_value.number_float);
21817 return (*lhs.m_value.binary) < (*rhs.m_value.binary);
21826 return static_cast<number_float_t>(lhs.m_value.number_integer) < rhs.m_value.number_float;
21830 return lhs.m_value.number_float <
static_cast<number_float_t>(rhs.m_value.number_integer);
21834 return static_cast<number_float_t>(lhs.m_value.number_unsigned) < rhs.m_value.number_float;
21838 return lhs.m_value.number_float <
static_cast<number_float_t>(rhs.m_value.number_unsigned);
21842 return lhs.m_value.number_integer <
static_cast<number_integer_t>(rhs.m_value.number_unsigned);
21846 return static_cast<number_integer_t>(lhs.m_value.number_unsigned) < rhs.m_value.number_integer;
21857 template<
typename ScalarType,
typename std::enable_if<
21858 std::is_scalar<ScalarType>::value,
int>
::type = 0>
21866 template<
typename ScalarType,
typename std::enable_if<
21867 std::is_scalar<ScalarType>::value,
int>
::type = 0>
21877 return !(rhs < lhs);
21882 template<
typename ScalarType,
typename std::enable_if<
21883 std::is_scalar<ScalarType>::value,
int>
::type = 0>
21891 template<
typename ScalarType,
typename std::enable_if<
21892 std::is_scalar<ScalarType>::value,
int>
::type = 0>
21902 return !(lhs <= rhs);
21907 template<
typename ScalarType,
typename std::enable_if<
21908 std::is_scalar<ScalarType>::value,
int>
::type = 0>
21916 template<
typename ScalarType,
typename std::enable_if<
21917 std::is_scalar<ScalarType>::value,
int>
::type = 0>
21927 return !(lhs < rhs);
21932 template<
typename ScalarType,
typename std::enable_if<
21933 std::is_scalar<ScalarType>::value,
int>
::type = 0>
21941 template<
typename ScalarType,
typename std::enable_if<
21942 std::is_scalar<ScalarType>::value,
int>
::type = 0>
21962 const bool pretty_print = o.width() > 0;
21963 const auto indentation = pretty_print ? o.width() : 0;
21970 s.dump(j, pretty_print,
false,
static_cast<unsigned int>(indentation));
21998 template<
typename InputType>
22002 const bool allow_exceptions =
true,
22003 const bool ignore_comments =
false)
22006 parser(
detail::input_adapter(std::forward<InputType>(i)), cb, allow_exceptions, ignore_comments).parse(
true, result);
22012 template<
typename IteratorType>
22017 const bool allow_exceptions =
true,
22018 const bool ignore_comments =
false)
22021 parser(
detail::input_adapter(std::move(first), std::move(last)), cb, allow_exceptions, ignore_comments).parse(
true, result);
22029 const
bool allow_exceptions = true,
22030 const
bool ignore_comments = false)
22033 parser(i.get(), cb, allow_exceptions, ignore_comments).parse(
true, result);
22039 template<
typename InputType>
22041 const bool ignore_comments =
false)
22043 return parser(
detail::input_adapter(std::forward<InputType>(i)),
nullptr,
false, ignore_comments).accept(
true);
22048 template<
typename IteratorType>
22049 static bool accept(IteratorType first, IteratorType last,
22050 const bool ignore_comments =
false)
22052 return parser(
detail::input_adapter(std::move(first), std::move(last)),
nullptr,
false, ignore_comments).accept(
true);
22057 static
bool accept(detail::span_input_adapter&& i,
22058 const
bool ignore_comments = false)
22060 return parser(i.get(),
nullptr,
false, ignore_comments).accept(
true);
22065 template <
typename InputType,
typename SAX>
22069 const
bool strict = true,
22070 const
bool ignore_comments = false)
22074 ? parser(std::move(ia),
nullptr,
true, ignore_comments).sax_parse(sax, strict)
22080 template<
class IteratorType,
class SAX>
22082 static
bool sax_parse(IteratorType first, IteratorType last, SAX* sax,
22084 const
bool strict = true,
22085 const
bool ignore_comments = false)
22089 ? parser(std::move(ia),
nullptr,
true, ignore_comments).sax_parse(sax, strict)
22098 template <
typename SAX>
22103 const
bool strict = true,
22104 const
bool ignore_comments = false)
22109 ? parser(std::move(ia),
nullptr,
true, ignore_comments).sax_parse(sax, strict)
22160 return "discarded";
22181#if JSON_DIAGNOSTICS
22198 std::vector<std::uint8_t> result;
22221 std::vector<std::uint8_t> result;
22243 const bool use_size =
false,
22244 const bool use_type =
false)
22246 std::vector<std::uint8_t> result;
22247 to_ubjson(j, result, use_size, use_type);
22254 const bool use_size =
false,
const bool use_type =
false)
22262 const bool use_size =
false,
const bool use_type =
false)
22270 const bool use_size =
false,
22271 const bool use_type =
false)
22273 std::vector<std::uint8_t> result;
22274 to_bjdata(j, result, use_size, use_type);
22281 const bool use_size =
false,
const bool use_type =
false)
22289 const bool use_size =
false,
const bool use_type =
false)
22298 std::vector<std::uint8_t> result;
22319 template<
typename InputType>
22322 const bool strict =
true,
22323 const bool allow_exceptions =
true,
22335 template<
typename IteratorType>
22338 const bool strict =
true,
22339 const bool allow_exceptions =
true,
22349 template<
typename T>
22353 const
bool strict = true,
22354 const
bool allow_exceptions = true,
22357 return from_cbor(ptr, ptr + len, strict, allow_exceptions, tag_handler);
22364 const
bool strict = true,
22365 const
bool allow_exceptions = true,
22378 template<
typename InputType>
22381 const bool strict =
true,
22382 const bool allow_exceptions =
true)
22393 template<
typename IteratorType>
22396 const bool strict =
true,
22397 const bool allow_exceptions =
true)
22406 template<
typename T>
22410 const
bool strict = true,
22411 const
bool allow_exceptions = true)
22413 return from_msgpack(ptr, ptr + len, strict, allow_exceptions);
22419 const
bool strict = true,
22420 const
bool allow_exceptions = true)
22432 template<
typename InputType>
22435 const bool strict =
true,
22436 const bool allow_exceptions =
true)
22447 template<
typename IteratorType>
22450 const bool strict =
true,
22451 const bool allow_exceptions =
true)
22460 template<
typename T>
22464 const
bool strict = true,
22465 const
bool allow_exceptions = true)
22467 return from_ubjson(ptr, ptr + len, strict, allow_exceptions);
22473 const
bool strict = true,
22474 const
bool allow_exceptions = true)
22487 template<
typename InputType>
22490 const bool strict =
true,
22491 const bool allow_exceptions =
true)
22502 template<
typename IteratorType>
22505 const bool strict =
true,
22506 const bool allow_exceptions =
true)
22515 template<
typename T>
22518 const bool strict =
true,
22519 const bool allow_exceptions =
true)
22521 return from_bjdata(ptr, ptr + len, strict, allow_exceptions);
22526 const bool strict =
true,
22527 const bool allow_exceptions =
true)
22540 template<
typename InputType>
22543 const bool strict =
true,
22544 const bool allow_exceptions =
true)
22555 template<
typename IteratorType>
22558 const bool strict =
true,
22559 const bool allow_exceptions =
true)
22568 template<
typename T>
22572 const
bool strict = true,
22573 const
bool allow_exceptions = true)
22575 return from_bson(ptr, ptr + len, strict, allow_exceptions);
22581 const
bool strict = true,
22582 const
bool allow_exceptions = true)
22604 return ptr.get_unchecked(
this);
22607 template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value,
int> = 0>
22611 return ptr.get_unchecked(
this);
22618 return ptr.get_unchecked(
this);
22621 template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value,
int> = 0>
22625 return ptr.get_unchecked(
this);
22632 return ptr.get_checked(
this);
22635 template<
typename BasicJsonType>
22637 reference at(const ::nlohmann::json_pointer<BasicJsonType>& ptr)
22639 return ptr.get_checked(
this);
22646 return ptr.get_checked(
this);
22649 template<
typename BasicJsonType>
22653 return ptr.get_checked(
this);
22661 json_pointer::flatten(
"", *
this, result);
22669 return json_pointer::unflatten(*
this);
22689 enum class patch_operations {add, remove,
replace, move, copy, test, invalid};
22691 const auto get_op = [](
const std::string & op)
22695 return patch_operations::add;
22697 if (op ==
"remove")
22699 return patch_operations::remove;
22701 if (op ==
"replace")
22703 return patch_operations::replace;
22707 return patch_operations::move;
22711 return patch_operations::copy;
22715 return patch_operations::test;
22718 return patch_operations::invalid;
22733 if (top_pointer != ptr)
22735 result.at(top_pointer);
22739 const auto last_path = ptr.back();
22743 switch (parent.m_type)
22749 parent[last_path] = val;
22755 if (last_path ==
"-")
22758 parent.push_back(val);
22762 const auto idx = json_pointer::template array_index<basic_json_t>(last_path);
22770 parent.insert(parent.begin() +
static_cast<difference_type>(idx), val);
22789 const auto operation_remove = [
this, &result](
json_pointer & ptr)
22792 const auto last_path = ptr.back();
22797 if (parent.is_object())
22800 auto it = parent.find(last_path);
22810 else if (parent.is_array())
22813 parent.erase(json_pointer::template array_index<basic_json_t>(last_path));
22824 for (
const auto& val : json_patch)
22827 const auto get_value = [&val](
const std::string & op,
22828 const std::string & member,
22832 auto it = val.m_value.object->find(member);
22835 const auto error_msg = (op ==
"op") ?
"operation" :
detail::concat(
"operation '", op,
'\'');
22862 const auto op = get_value(
"op",
"op",
true).template get<std::string>();
22863 const auto path = get_value(op,
"path",
true).template get<std::string>();
22866 switch (get_op(op))
22868 case patch_operations::add:
22870 operation_add(ptr, get_value(
"add",
"value",
false));
22874 case patch_operations::remove:
22876 operation_remove(ptr);
22880 case patch_operations::replace:
22883 result.at(ptr) = get_value(
"replace",
"value",
false);
22887 case patch_operations::move:
22889 const auto from_path = get_value(
"move",
"from",
true).template get<std::string>();
22899 operation_remove(from_ptr);
22900 operation_add(ptr, v);
22904 case patch_operations::copy:
22906 const auto from_path = get_value(
"copy",
"from",
true).template get<std::string>();
22915 operation_add(ptr, v);
22919 case patch_operations::test:
22921 bool success =
false;
22926 success = (result.at(ptr) == get_value(
"test",
"value",
false));
22942 case patch_operations::invalid:
22959 const std::string& path =
"")
22965 if (source == target)
22970 if (source.type() != target.type())
22975 {
"op",
"replace"}, {
"path", path}, {
"value", target}
22980 switch (source.type())
22986 while (i < source.size() && i < target.size())
22990 result.insert(result.end(), temp_diff.begin(), temp_diff.end());
22999 while (i < source.size())
23003 result.insert(result.begin() + end_index,
object(
23012 while (i < target.size())
23018 {
"value", target[i]}
23029 for (
auto it = source.cbegin(); it != source.cend(); ++it)
23034 if (target.find(it.key()) != target.end())
23037 auto temp_diff = diff(it.value(), target[it.key()], path_key);
23038 result.insert(result.end(), temp_diff.begin(), temp_diff.end());
23043 result.push_back(
object(
23045 {
"op",
"remove"}, {
"path", path_key}
23051 for (
auto it = target.cbegin(); it != target.cend(); ++it)
23053 if (source.find(it.key()) == source.end())
23059 {
"op",
"add"}, {
"path", path_key},
23060 {
"value", it.value()}
23081 {
"op",
"replace"}, {
"path", path}, {
"value", target}
23109 for (
auto it = apply_patch.begin(); it != apply_patch.end(); ++it)
23111 if (it.value().is_null())
23123 *
this = apply_patch;
23174#ifndef JSON_HAS_CPP_20
23180 is_nothrow_move_constructible<nlohmann::NLOHMANN_BASIC_JSON_TPL>::value&&
23181 is_nothrow_move_assignable<nlohmann::NLOHMANN_BASIC_JSON_TPL>::value)
23210#if defined(__clang__)
23211 #pragma clang diagnostic pop
23216#undef JSON_INTERNAL_CATCH
23218#undef JSON_PRIVATE_UNLESS_TESTED
23219#undef NLOHMANN_BASIC_JSON_TPL_DECLARATION
23220#undef NLOHMANN_BASIC_JSON_TPL
23221#undef JSON_EXPLICIT
23222#undef NLOHMANN_CAN_CALL_STD_FUNC_IMPL
23223#undef JSON_NO_UNIQUE_ADDRESS
23225#ifndef JSON_TEST_KEEP_MACROS
23228 #undef JSON_HAS_CPP_11
23229 #undef JSON_HAS_CPP_14
23230 #undef JSON_HAS_CPP_17
23231 #undef JSON_HAS_CPP_20
23232 #undef JSON_HAS_FILESYSTEM
23233 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
23234 #undef JSON_HAS_THREE_WAY_COMPARISON
23240#undef JSON_HEDLEY_ALWAYS_INLINE
23241#undef JSON_HEDLEY_ARM_VERSION
23242#undef JSON_HEDLEY_ARM_VERSION_CHECK
23243#undef JSON_HEDLEY_ARRAY_PARAM
23244#undef JSON_HEDLEY_ASSUME
23245#undef JSON_HEDLEY_BEGIN_C_DECLS
23246#undef JSON_HEDLEY_CLANG_HAS_ATTRIBUTE
23247#undef JSON_HEDLEY_CLANG_HAS_BUILTIN
23248#undef JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE
23249#undef JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE
23250#undef JSON_HEDLEY_CLANG_HAS_EXTENSION
23251#undef JSON_HEDLEY_CLANG_HAS_FEATURE
23252#undef JSON_HEDLEY_CLANG_HAS_WARNING
23253#undef JSON_HEDLEY_COMPCERT_VERSION
23254#undef JSON_HEDLEY_COMPCERT_VERSION_CHECK
23255#undef JSON_HEDLEY_CONCAT
23256#undef JSON_HEDLEY_CONCAT3
23257#undef JSON_HEDLEY_CONCAT3_EX
23258#undef JSON_HEDLEY_CONCAT_EX
23259#undef JSON_HEDLEY_CONST
23260#undef JSON_HEDLEY_CONSTEXPR
23261#undef JSON_HEDLEY_CONST_CAST
23262#undef JSON_HEDLEY_CPP_CAST
23263#undef JSON_HEDLEY_CRAY_VERSION
23264#undef JSON_HEDLEY_CRAY_VERSION_CHECK
23265#undef JSON_HEDLEY_C_DECL
23266#undef JSON_HEDLEY_DEPRECATED
23267#undef JSON_HEDLEY_DEPRECATED_FOR
23268#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL
23269#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_
23270#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED
23271#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES
23272#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS
23273#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION
23274#undef JSON_HEDLEY_DIAGNOSTIC_POP
23275#undef JSON_HEDLEY_DIAGNOSTIC_PUSH
23276#undef JSON_HEDLEY_DMC_VERSION
23277#undef JSON_HEDLEY_DMC_VERSION_CHECK
23278#undef JSON_HEDLEY_EMPTY_BASES
23279#undef JSON_HEDLEY_EMSCRIPTEN_VERSION
23280#undef JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK
23281#undef JSON_HEDLEY_END_C_DECLS
23282#undef JSON_HEDLEY_FLAGS
23283#undef JSON_HEDLEY_FLAGS_CAST
23284#undef JSON_HEDLEY_GCC_HAS_ATTRIBUTE
23285#undef JSON_HEDLEY_GCC_HAS_BUILTIN
23286#undef JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE
23287#undef JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE
23288#undef JSON_HEDLEY_GCC_HAS_EXTENSION
23289#undef JSON_HEDLEY_GCC_HAS_FEATURE
23290#undef JSON_HEDLEY_GCC_HAS_WARNING
23291#undef JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK
23292#undef JSON_HEDLEY_GCC_VERSION
23293#undef JSON_HEDLEY_GCC_VERSION_CHECK
23294#undef JSON_HEDLEY_GNUC_HAS_ATTRIBUTE
23295#undef JSON_HEDLEY_GNUC_HAS_BUILTIN
23296#undef JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE
23297#undef JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE
23298#undef JSON_HEDLEY_GNUC_HAS_EXTENSION
23299#undef JSON_HEDLEY_GNUC_HAS_FEATURE
23300#undef JSON_HEDLEY_GNUC_HAS_WARNING
23301#undef JSON_HEDLEY_GNUC_VERSION
23302#undef JSON_HEDLEY_GNUC_VERSION_CHECK
23303#undef JSON_HEDLEY_HAS_ATTRIBUTE
23304#undef JSON_HEDLEY_HAS_BUILTIN
23305#undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE
23306#undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS
23307#undef JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE
23308#undef JSON_HEDLEY_HAS_EXTENSION
23309#undef JSON_HEDLEY_HAS_FEATURE
23310#undef JSON_HEDLEY_HAS_WARNING
23311#undef JSON_HEDLEY_IAR_VERSION
23312#undef JSON_HEDLEY_IAR_VERSION_CHECK
23313#undef JSON_HEDLEY_IBM_VERSION
23314#undef JSON_HEDLEY_IBM_VERSION_CHECK
23315#undef JSON_HEDLEY_IMPORT
23316#undef JSON_HEDLEY_INLINE
23317#undef JSON_HEDLEY_INTEL_CL_VERSION
23318#undef JSON_HEDLEY_INTEL_CL_VERSION_CHECK
23319#undef JSON_HEDLEY_INTEL_VERSION
23320#undef JSON_HEDLEY_INTEL_VERSION_CHECK
23321#undef JSON_HEDLEY_IS_CONSTANT
23322#undef JSON_HEDLEY_IS_CONSTEXPR_
23323#undef JSON_HEDLEY_LIKELY
23324#undef JSON_HEDLEY_MALLOC
23325#undef JSON_HEDLEY_MCST_LCC_VERSION
23326#undef JSON_HEDLEY_MCST_LCC_VERSION_CHECK
23327#undef JSON_HEDLEY_MESSAGE
23328#undef JSON_HEDLEY_MSVC_VERSION
23329#undef JSON_HEDLEY_MSVC_VERSION_CHECK
23330#undef JSON_HEDLEY_NEVER_INLINE
23331#undef JSON_HEDLEY_NON_NULL
23332#undef JSON_HEDLEY_NO_ESCAPE
23333#undef JSON_HEDLEY_NO_RETURN
23334#undef JSON_HEDLEY_NO_THROW
23335#undef JSON_HEDLEY_NULL
23336#undef JSON_HEDLEY_PELLES_VERSION
23337#undef JSON_HEDLEY_PELLES_VERSION_CHECK
23338#undef JSON_HEDLEY_PGI_VERSION
23339#undef JSON_HEDLEY_PGI_VERSION_CHECK
23340#undef JSON_HEDLEY_PREDICT
23341#undef JSON_HEDLEY_PRINTF_FORMAT
23342#undef JSON_HEDLEY_PRIVATE
23343#undef JSON_HEDLEY_PUBLIC
23344#undef JSON_HEDLEY_PURE
23345#undef JSON_HEDLEY_REINTERPRET_CAST
23346#undef JSON_HEDLEY_REQUIRE
23347#undef JSON_HEDLEY_REQUIRE_CONSTEXPR
23348#undef JSON_HEDLEY_REQUIRE_MSG
23349#undef JSON_HEDLEY_RESTRICT
23350#undef JSON_HEDLEY_RETURNS_NON_NULL
23351#undef JSON_HEDLEY_SENTINEL
23352#undef JSON_HEDLEY_STATIC_ASSERT
23353#undef JSON_HEDLEY_STATIC_CAST
23354#undef JSON_HEDLEY_STRINGIFY
23355#undef JSON_HEDLEY_STRINGIFY_EX
23356#undef JSON_HEDLEY_SUNPRO_VERSION
23357#undef JSON_HEDLEY_SUNPRO_VERSION_CHECK
23358#undef JSON_HEDLEY_TINYC_VERSION
23359#undef JSON_HEDLEY_TINYC_VERSION_CHECK
23360#undef JSON_HEDLEY_TI_ARMCL_VERSION
23361#undef JSON_HEDLEY_TI_ARMCL_VERSION_CHECK
23362#undef JSON_HEDLEY_TI_CL2000_VERSION
23363#undef JSON_HEDLEY_TI_CL2000_VERSION_CHECK
23364#undef JSON_HEDLEY_TI_CL430_VERSION
23365#undef JSON_HEDLEY_TI_CL430_VERSION_CHECK
23366#undef JSON_HEDLEY_TI_CL6X_VERSION
23367#undef JSON_HEDLEY_TI_CL6X_VERSION_CHECK
23368#undef JSON_HEDLEY_TI_CL7X_VERSION
23369#undef JSON_HEDLEY_TI_CL7X_VERSION_CHECK
23370#undef JSON_HEDLEY_TI_CLPRU_VERSION
23371#undef JSON_HEDLEY_TI_CLPRU_VERSION_CHECK
23372#undef JSON_HEDLEY_TI_VERSION
23373#undef JSON_HEDLEY_TI_VERSION_CHECK
23374#undef JSON_HEDLEY_UNAVAILABLE
23375#undef JSON_HEDLEY_UNLIKELY
23376#undef JSON_HEDLEY_UNPREDICTABLE
23377#undef JSON_HEDLEY_UNREACHABLE
23378#undef JSON_HEDLEY_UNREACHABLE_RETURN
23379#undef JSON_HEDLEY_VERSION
23380#undef JSON_HEDLEY_VERSION_DECODE_MAJOR
23381#undef JSON_HEDLEY_VERSION_DECODE_MINOR
23382#undef JSON_HEDLEY_VERSION_DECODE_REVISION
23383#undef JSON_HEDLEY_VERSION_ENCODE
23384#undef JSON_HEDLEY_WARNING
23385#undef JSON_HEDLEY_WARN_UNUSED_RESULT
23386#undef JSON_HEDLEY_WARN_UNUSED_RESULT_MSG
23387#undef JSON_HEDLEY_FALL_THROUGH
nlohmann::json json
Definition: API.cpp:15
a class to store JSON values
Definition: json.hpp:18239
ValueType & get_to(ValueType &v) const
Definition: json.hpp:19940
void insert(const_iterator first, const_iterator last)
inserts range of elements into object
Definition: json.hpp:21467
detail::parser_callback_t< basic_json > parser_callback_t
per-element parser callback type
Definition: json.hpp:18935
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_bjdata(const T *ptr, std::size_t len, const bool strict=true, const bool allow_exceptions=true)
Definition: json.hpp:22517
const_reference operator[](const json_pointer &ptr) const
access specified element via JSON Pointer
Definition: json.hpp:22616
reference operator[](const json_pointer &ptr)
access specified element via JSON Pointer
Definition: json.hpp:22602
friend bool operator==(const_reference lhs, ScalarType rhs) noexcept
comparison: equal
Definition: json.hpp:21740
constexpr bool is_number_float() const noexcept
return whether value is a floating-point number
Definition: json.hpp:19479
const_reference operator[](T *key) const
Definition: json.hpp:20294
NumberIntegerType number_integer_t
a type for a number (integer)
Definition: json.hpp:18496
friend bool operator==(const_reference lhs, const_reference rhs) noexcept
comparison: equal
Definition: json.hpp:21660
void update(const_reference j, bool merge_objects=false)
updates a JSON object from another object, overwriting existing keys
Definition: json.hpp:21492
static bool sax_parse(InputType &&i, SAX *sax, input_format_t format=input_format_t::json, const bool strict=true, const bool ignore_comments=false)
generate SAX events
Definition: json.hpp:22067
static std::vector< std::uint8_t > to_bjdata(const basic_json &j, const bool use_size=false, const bool use_type=false)
create a BJData serialization of a given JSON value
Definition: json.hpp:22269
::nlohmann::json_pointer< StringType > json_pointer
JSON Pointer, see nlohmann::json_pointer.
Definition: json.hpp:18305
ReferenceType get_ref()
get a reference value (implicit)
Definition: json.hpp:19963
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json parse(InputType &&i, const parser_callback_t cb=nullptr, const bool allow_exceptions=true, const bool ignore_comments=false)
deserialize from a compatible input
Definition: json.hpp:22000
reference emplace_back(Args &&... args)
add an object to an array
Definition: json.hpp:21293
basic_json(const value_t v)
create an empty value with a given type
Definition: json.hpp:18948
iterator find(KeyType &&key)
find an element in a JSON object
Definition: json.hpp:20762
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_bjdata(detail::span_input_adapter &&i, const bool strict=true, const bool allow_exceptions=true)
Definition: json.hpp:22525
static std::vector< std::uint8_t > to_bson(const basic_json &j)
create a BSON serialization of a given JSON value
Definition: json.hpp:22296
value_type & reference
the type of an element reference
Definition: json.hpp:18350
void erase(const size_type idx)
remove element from a JSON array given an index
Definition: json.hpp:20702
detail::out_of_range out_of_range
Definition: json.hpp:18331
const_reference at(const typename object_t::key_type &key) const
access specified object element with bounds checking
Definition: json.hpp:20153
reference at(const typename object_t::key_type &key)
access specified object element with bounds checking
Definition: json.hpp:20115
binary_t & get_binary()
get a binary value
Definition: json.hpp:20034
basic_json(InputIT first, InputIT last)
construct a JSON container given an iterator range
Definition: json.hpp:19162
static std::vector< std::uint8_t > to_msgpack(const basic_json &j)
create a MessagePack serialization of a given JSON value
Definition: json.hpp:22219
friend bool operator==(ScalarType lhs, const_reference rhs) noexcept
comparison: equal
Definition: json.hpp:21749
basic_json(const JsonRef &ref)
Definition: json.hpp:19272
static std::vector< std::uint8_t > to_cbor(const basic_json &j)
create a CBOR serialization of a given JSON value
Definition: json.hpp:22196
basic_json & operator=(basic_json other) noexcept(std::is_nothrow_move_constructible< value_t >::value &&std::is_nothrow_move_assignable< value_t >::value &&std::is_nothrow_move_constructible< json_value >::value &&std::is_nothrow_move_assignable< json_value >::value)
copy assignment
Definition: json.hpp:19361
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json array(initializer_list_t init={})
explicitly create an array from an initializer list
Definition: json.hpp:19134
reference back()
access the last element
Definition: json.hpp:20488
const binary_t & get_binary() const
get a binary value
Definition: json.hpp:20046
static bool accept(InputType &&i, const bool ignore_comments=false)
check if the input is valid JSON
Definition: json.hpp:22040
static void to_bjdata(const basic_json &j, detail::output_adapter< char > o, const bool use_size=false, const bool use_type=false)
create a BJData serialization of a given JSON value
Definition: json.hpp:22288
StringType string_t
a type for a string
Definition: json.hpp:18488
void push_back(const basic_json &val)
add an object to an array
Definition: json.hpp:21205
reference at(KeyType &&key)
access specified object element with bounds checking
Definition: json.hpp:20135
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json meta()
returns version information on the library
Definition: json.hpp:18389
ValueType value(const json_pointer &ptr, const ValueType &default_value) const
access specified object element via JSON Pointer with default value
Definition: json.hpp:20428
ObjectType< StringType, basic_json, default_object_comparator_t, AllocatorType< std::pair< const StringType, basic_json > > > object_t
a type for an object
Definition: json.hpp:18480
std::size_t size_type
a type to represent container sizes
Definition: json.hpp:18357
ValueType & get_to(ValueType &v) const noexcept(noexcept(JSONSerializer< ValueType >::from_json(std::declval< const basic_json_t & >(), v)))
get a value (explicit)
Definition: json.hpp:19927
std::ptrdiff_t difference_type
a type to represent differences between iterators
Definition: json.hpp:18355
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json binary(const typename binary_t::container_type &init)
explicitly create a binary array (without subtype)
Definition: json.hpp:19090
reference operator+=(basic_json &&val)
add an object to an array
Definition: json.hpp:21197
basic_json(const BasicJsonType &val)
create a JSON value from an existing one
Definition: json.hpp:18982
typename std::allocator_traits< allocator_type >::const_pointer const_pointer
the type of an element const pointer
Definition: json.hpp:18365
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_bson(IteratorType first, IteratorType last, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in BSON format
Definition: json.hpp:22557
size_type count(const typename object_t::key_type &key) const
returns the number of occurrences of a key in a JSON object
Definition: json.hpp:20792
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_bjdata(InputType &&i, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in BJData format
Definition: json.hpp:22489
typename std::allocator_traits< allocator_type >::pointer pointer
the type of an element pointer
Definition: json.hpp:18363
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_cbor(InputType &&i, const bool strict=true, const bool allow_exceptions=true, const cbor_tag_handler_t tag_handler=cbor_tag_handler_t::error)
create a JSON value from an input in CBOR format
Definition: json.hpp:22321
BooleanType boolean_t
a type for a boolean
Definition: json.hpp:18492
void push_back(initializer_list_t init)
add an object to an object
Definition: json.hpp:21268
string_t dump(const int indent=-1, const char indent_char=' ', const bool ensure_ascii=false, const error_handler_t error_handler=error_handler_t::strict) const
serialization
Definition: json.hpp:19401
reference operator[](typename object_t::key_type key)
access specified object element
Definition: json.hpp:20250
static bool accept(IteratorType first, IteratorType last, const bool ignore_comments=false)
check if the input is valid JSON
Definition: json.hpp:22049
std::decay< ValueType >::type value(KeyType &&key, ValueType &&default_value) const
access specified object element with default value
Definition: json.hpp:20396
IteratorType erase(IteratorType pos)
remove element given an iterator
Definition: json.hpp:20509
const_iterator find(const typename object_t::key_type &key) const
find an element in a JSON object
Definition: json.hpp:20746
static void to_bson(const basic_json &j, detail::output_adapter< std::uint8_t > o)
create a BSON serialization of a given JSON value
Definition: json.hpp:22305
friend bool operator!=(const_reference lhs, ScalarType rhs) noexcept
comparison: not equal
Definition: json.hpp:21765
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_bson(InputType &&i, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in BSON format
Definition: json.hpp:22542
constexpr bool is_structured() const noexcept
return whether type is structured
Definition: json.hpp:19437
friend bool operator<=(ScalarType lhs, const_reference rhs) noexcept
comparison: less than or equal
Definition: json.hpp:21893
void update(const_iterator first, const_iterator last, bool merge_objects=false)
updates a JSON object from another object, overwriting existing keys
Definition: json.hpp:21499
friend bool operator<(const_reference lhs, ScalarType rhs) noexcept
comparison: less than
Definition: json.hpp:21859
reference at(size_type idx)
access specified array element with bounds checking
Definition: json.hpp:20069
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json binary(typename binary_t::container_type &&init, typename binary_t::subtype_type subtype)
explicitly create a binary array (with subtype)
Definition: json.hpp:19123
constexpr bool is_primitive() const noexcept
return whether type is primitive
Definition: json.hpp:19430
constexpr bool is_number_unsigned() const noexcept
return whether value is an unsigned integer number
Definition: json.hpp:19472
static void to_cbor(const basic_json &j, detail::output_adapter< char > o)
create a CBOR serialization of a given JSON value
Definition: json.hpp:22212
void swap(object_t &other)
exchanges the values
Definition: json.hpp:21590
constexpr bool is_object() const noexcept
return whether value is an object
Definition: json.hpp:19486
bool contains(KeyType &&key) const
check the existence of an element in a JSON object
Definition: json.hpp:20819
reference operator[](KeyType &&key)
access specified object element
Definition: json.hpp:20303
const_reference front() const
access the first element
Definition: json.hpp:20481
constexpr value_t type() const noexcept
return the type of the JSON value (explicit)
Definition: json.hpp:19423
NumberFloatType number_float_t
a type for a number (floating-point)
Definition: json.hpp:18504
json_reverse_iterator< typename basic_json::iterator > reverse_iterator
a reverse iterator for a basic_json container
Definition: json.hpp:18372
friend std::ostream & operator<<(std::ostream &o, const basic_json &j)
serialize to stream
Definition: json.hpp:21959
friend bool operator<=(const_reference lhs, const_reference rhs) noexcept
comparison: less than or equal
Definition: json.hpp:21875
basic_json(const basic_json &other)
copy constructor
Definition: json.hpp:19276
~basic_json() noexcept
destructor
Definition: json.hpp:19382
const_iterator find(KeyType &&key) const
find an element in a JSON object
Definition: json.hpp:20778
static std::vector< std::uint8_t > to_ubjson(const basic_json &j, const bool use_size=false, const bool use_type=false)
create a UBJSON serialization of a given JSON value
Definition: json.hpp:22242
basic_json(basic_json &&other) noexcept
move constructor
Definition: json.hpp:19344
friend bool operator>(ScalarType lhs, const_reference rhs) noexcept
comparison: greater than
Definition: json.hpp:21918
bool contains(const typename object_t::key_type &key) const
check the existence of an element in a JSON object
Definition: json.hpp:20810
static void to_ubjson(const basic_json &j, detail::output_adapter< char > o, const bool use_size=false, const bool use_type=false)
create a UBJSON serialization of a given JSON value
Definition: json.hpp:22261
friend bool operator!=(const_reference lhs, const_reference rhs) noexcept
comparison: not equal
Definition: json.hpp:21756
iterator insert(const_iterator pos, size_type cnt, const basic_json &val)
inserts copies of element into array
Definition: json.hpp:21396
friend bool operator<(ScalarType lhs, const_reference rhs) noexcept
comparison: less than
Definition: json.hpp:21868
json_value m_value
the value of the current element
Definition: json.hpp:22179
void swap(typename binary_t::container_type &other)
exchanges the values
Definition: json.hpp:21635
friend bool operator>=(const_reference lhs, const_reference rhs) noexcept
comparison: greater than or equal
Definition: json.hpp:21925
void swap(array_t &other)
exchanges the values
Definition: json.hpp:21575
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json binary(const typename binary_t::container_type &init, typename binary_t::subtype_type subtype)
explicitly create a binary array (with subtype)
Definition: json.hpp:19101
std::less< StringType > default_object_comparator_t
default object key comparator type The actual object key comparator type (object_comparator_t) may be...
Definition: json.hpp:18471
ReferenceType get_ref() const
get a reference value (implicit)
Definition: json.hpp:19974
const_reference at(KeyType &&key) const
access specified object element with bounds checking
Definition: json.hpp:20173
iterator insert(const_iterator pos, const_iterator first, const_iterator last)
inserts range of elements into array
Definition: json.hpp:21416
auto get() noexcept -> decltype(std::declval< basic_json_t & >().template get_ptr< PointerType >())
get a pointer value (explicit)
Definition: json.hpp:19914
const_reference at(const json_pointer &ptr) const
access specified element via JSON Pointer
Definition: json.hpp:22644
void merge_patch(const basic_json &apply_patch)
applies a JSON Merge Patch
Definition: json.hpp:23101
auto get_ptr() noexcept -> decltype(std::declval< basic_json_t & >().get_impl_ptr(std::declval< PointerType >()))
get a pointer value (implicit)
Definition: json.hpp:19674
iterator insert(const_iterator pos, initializer_list_t ilist)
inserts elements from initializer list into array
Definition: json.hpp:21447
ArrayType< basic_json, AllocatorType< basic_json > > array_t
a type for an array
Definition: json.hpp:18484
Array get_to(T(&v)[N]) const noexcept(noexcept(JSONSerializer< Array >::from_json(std::declval< const basic_json_t & >(), v)))
Definition: json.hpp:19951
friend bool operator>(const_reference lhs, const_reference rhs) noexcept
comparison: greater than
Definition: json.hpp:21900
const_reference operator[](KeyType &&key) const
access specified object element
Definition: json.hpp:20327
IteratorType erase(IteratorType first, IteratorType last)
remove elements given an iterator range
Definition: json.hpp:20579
constexpr bool is_boolean() const noexcept
return whether value is a boolean
Definition: json.hpp:19451
void swap(reference other) noexcept(std::is_nothrow_move_constructible< value_t >::value &&std::is_nothrow_move_assignable< value_t >::value &&std::is_nothrow_move_constructible< json_value >::value &&std::is_nothrow_move_assignable< json_value >::value)
exchanges the values
Definition: json.hpp:21546
friend bool operator>=(ScalarType lhs, const_reference rhs) noexcept
comparison: greater than or equal
Definition: json.hpp:21943
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_msgpack(IteratorType first, IteratorType last, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in MessagePack format
Definition: json.hpp:22395
constexpr bool is_binary() const noexcept
return whether value is a binary array
Definition: json.hpp:19507
JSON_HEDLEY_DEPRECATED_FOR(3.11.0, basic_json::json_pointer or nlohmann::json_pointer< basic_json::string_t >) const _reference operator[](const
access specified element via JSON Pointer
Definition: json.hpp:22622
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json object(initializer_list_t init={})
explicitly create an object from an initializer list
Definition: json.hpp:19142
iterator insert(const_iterator pos, basic_json &&val)
inserts element into array
Definition: json.hpp:21389
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_ubjson(IteratorType first, IteratorType last, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in UBJSON format
Definition: json.hpp:22449
reference operator[](size_type idx)
access specified array element
Definition: json.hpp:20191
friend bool operator>(const_reference lhs, ScalarType rhs) noexcept
comparison: greater than
Definition: json.hpp:21909
static void to_bson(const basic_json &j, detail::output_adapter< char > o)
create a BSON serialization of a given JSON value
Definition: json.hpp:22312
std::decay< ValueType >::type value(const char *key, ValueType &&default_value) const
Definition: json.hpp:20379
string_t value(KeyType &&key, const char *default_value) const
access specified object element with default value
Definition: json.hpp:20419
void swap(binary_t &other)
exchanges the values
Definition: json.hpp:21620
iter_impl< basic_json > iterator
an iterator for a basic_json container
Definition: json.hpp:18368
json_reverse_iterator< typename basic_json::const_iterator > const_reverse_iterator
a const reverse iterator for a basic_json container
Definition: json.hpp:18374
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_ubjson(InputType &&i, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in UBJSON format
Definition: json.hpp:22434
friend bool operator!=(ScalarType lhs, const_reference rhs) noexcept
comparison: not equal
Definition: json.hpp:21774
static void to_ubjson(const basic_json &j, detail::output_adapter< std::uint8_t > o, const bool use_size=false, const bool use_type=false)
create a UBJSON serialization of a given JSON value
Definition: json.hpp:22253
string_t value(const char *key, const char *default_value) const
Definition: json.hpp:20384
size_type count(KeyType &&key) const
returns the number of occurrences of a key in a JSON object
Definition: json.hpp:20802
void swap(string_t &other)
exchanges the values
Definition: json.hpp:21605
const_reference back() const
access the last element
Definition: json.hpp:20497
friend bool operator<(const_reference lhs, const_reference rhs) noexcept
comparison: less than
Definition: json.hpp:21781
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json binary(typename binary_t::container_type &&init)
explicitly create a binary array
Definition: json.hpp:19112
constexpr bool is_string() const noexcept
return whether value is a string
Definition: json.hpp:19500
constexpr bool is_array() const noexcept
return whether value is an array
Definition: json.hpp:19493
iterator insert_iterator(const_iterator pos, Args &&... args)
Definition: json.hpp:21350
JSON_HEDLEY_DEPRECATED_FOR(3.11.0, basic_json::json_pointer or nlohmann::json_pointer< basic_json::string_t >) ValueType value(const
access specified object element via JSON Pointer with default value
Definition: json.hpp:20449
friend bool operator>=(const_reference lhs, ScalarType rhs) noexcept
comparison: greater than or equal
Definition: json.hpp:21934
JSON_HEDLEY_RETURNS_NON_NULL const char * type_name() const noexcept
return the type as string
Definition: json.hpp:22143
const value_type & const_reference
the type of an element const reference
Definition: json.hpp:18352
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_cbor(IteratorType first, IteratorType last, const bool strict=true, const bool allow_exceptions=true, const cbor_tag_handler_t tag_handler=cbor_tag_handler_t::error)
create a JSON value from an input in CBOR format
Definition: json.hpp:22337
reference operator[](T *key)
Definition: json.hpp:20288
constexpr bool is_number() const noexcept
return whether value is a number
Definition: json.hpp:19458
friend std::ostream & operator>>(const basic_json &j, std::ostream &o)
serialize to stream
Definition: json.hpp:21981
reference operator+=(initializer_list_t init)
add an object to an object
Definition: json.hpp:21284
constexpr bool is_number_integer() const noexcept
return whether value is an integer number
Definition: json.hpp:19465
std::initializer_list< detail::json_ref< basic_json > > initializer_list_t
helper type for initializer lists of basic_json values
Definition: json.hpp:18313
static void to_cbor(const basic_json &j, detail::output_adapter< std::uint8_t > o)
create a CBOR serialization of a given JSON value
Definition: json.hpp:22205
detail::value_t value_t
Definition: json.hpp:18303
size_type erase(KeyType &&key)
remove element from a JSON object given a key
Definition: json.hpp:20695
static void to_msgpack(const basic_json &j, detail::output_adapter< char > o)
create a MessagePack serialization of a given JSON value
Definition: json.hpp:22235
const_reference operator[](const typename object_t::key_type &key) const
access specified object element
Definition: json.hpp:20272
detail::actual_object_comparator_t< basic_json > object_comparator_t
object key comparator type
Definition: json.hpp:18512
basic_json(std::nullptr_t=nullptr) noexcept
create a null object
Definition: json.hpp:18956
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_bjdata(IteratorType first, IteratorType last, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in BJData format
Definition: json.hpp:22504
JSON_HEDLEY_DEPRECATED_FOR(3.11.0, basic_json::json_pointer or nlohmann::json_pointer< basic_json::string_t >) reference operator[](const
Definition: json.hpp:22608
const_reference operator[](size_type idx) const
access specified array element
Definition: json.hpp:20237
AllocatorType< basic_json > allocator_type
the allocator type
Definition: json.hpp:18360
nlohmann::byte_container_with_subtype< BinaryType > binary_t
a type for a packed binary type
Definition: json.hpp:18508
JSONSerializer< T, SFINAE > json_serializer
Definition: json.hpp:18307
void push_back(const typename object_t::value_type &val)
add an object to an object
Definition: json.hpp:21237
JSON_HEDLEY_DEPRECATED_FOR(3.11.0, basic_json::json_pointer or nlohmann::json_pointer< basic_json::string_t >) reference at(const
Definition: json.hpp:22636
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json parse(IteratorType first, IteratorType last, const parser_callback_t cb=nullptr, const bool allow_exceptions=true, const bool ignore_comments=false)
deserialize from a pair of character iterators
Definition: json.hpp:22014
bool contains(const json_pointer &ptr) const
check the existence of an element in a JSON object given a JSON pointer
Definition: json.hpp:20826
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_msgpack(InputType &&i, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in MessagePack format
Definition: json.hpp:22380
string_t value(const typename object_t::key_type &key, const char *default_value) const
access specified object element with default value
Definition: json.hpp:20368
basic_json(CompatibleType &&val) noexcept(noexcept(//NOLINT(bugprone-forwarding-reference-overload, bugprone-exception-escape) JSONSerializer< U >::to_json(std::declval< basic_json_t & >(), std::forward< CompatibleType >(val))))
create a JSON value from compatible types
Definition: json.hpp:18968
NumberUnsignedType number_unsigned_t
a type for a number (unsigned)
Definition: json.hpp:18500
iterator find(const typename object_t::key_type &key)
find an element in a JSON object
Definition: json.hpp:20732
reference operator+=(const typename object_t::value_type &val)
add an object to an object
Definition: json.hpp:21260
friend bool operator<=(const_reference lhs, ScalarType rhs) noexcept
comparison: less than or equal
Definition: json.hpp:21884
std::decay< ValueType >::type value(const KeyType &key, ValueType &&default_value) const
access specified object element with default value
Definition: json.hpp:20347
friend std::istream & operator>>(std::istream &i, basic_json &j)
deserialize from stream
Definition: json.hpp:22128
basic_json(initializer_list_t init, bool type_deduction=true, value_t manual_type=value_t::array)
create a container (array or object) from an initializer list
Definition: json.hpp:19034
const_reference at(size_type idx) const
access specified array element with bounds checking
Definition: json.hpp:20092
iterator insert(const_iterator pos, const basic_json &val)
inserts element into array
Definition: json.hpp:21369
iter_impl< const basic_json > const_iterator
a const iterator for a basic_json container
Definition: json.hpp:18370
constexpr bool is_discarded() const noexcept
return whether value is discarded
Definition: json.hpp:19514
constexpr bool is_null() const noexcept
return whether value is null
Definition: json.hpp:19444
friend void swap(reference left, reference right) noexcept(std::is_nothrow_move_constructible< value_t >::value &&std::is_nothrow_move_assignable< value_t >::value &&std::is_nothrow_move_constructible< json_value >::value &&std::is_nothrow_move_assignable< json_value >::value)
exchanges the values
Definition: json.hpp:21563
static void to_bjdata(const basic_json &j, detail::output_adapter< std::uint8_t > o, const bool use_size=false, const bool use_type=false)
create a BJData serialization of a given JSON value
Definition: json.hpp:22280
auto get() const noexcept(noexcept(std::declval< const basic_json_t & >().template get_impl< ValueType >(detail::priority_tag< 4 > {}))) -> decltype(std::declval< const basic_json_t & >().template get_impl< ValueType >(detail::priority_tag< 4 > {}))
get a (pointer) value (explicit)
Definition: json.hpp:19873
std::pair< iterator, bool > emplace(Args &&... args)
add an object to an object if key does not exist
Definition: json.hpp:21318
static void to_msgpack(const basic_json &j, detail::output_adapter< std::uint8_t > o)
create a MessagePack serialization of a given JSON value
Definition: json.hpp:22228
reference operator+=(const basic_json &val)
add an object to an array
Definition: json.hpp:21229
size_type erase(const typename object_t::key_type &key)
remove element from a JSON object given a key
Definition: json.hpp:20684
basic_json(size_type cnt, const basic_json &val)
construct an array with count copies of given value
Definition: json.hpp:19149
static allocator_type get_allocator()
returns the allocator associated with the container
Definition: json.hpp:18381
constexpr auto get_ptr() const noexcept -> decltype(std::declval< const basic_json_t & >().get_impl_ptr(std::declval< PointerType >()))
get a pointer value (implicit)
Definition: json.hpp:19685
an internal type for a backed binary type
Definition: json.hpp:5274
byte_container_with_subtype(const container_type &b, subtype_type subtype_) noexcept(noexcept(container_type(b)))
Definition: json.hpp:5295
BinaryType container_type
Definition: json.hpp:5276
byte_container_with_subtype(const container_type &b) noexcept(noexcept(container_type(b)))
Definition: json.hpp:5285
byte_container_with_subtype(container_type &&b) noexcept(noexcept(container_type(std::move(b))))
Definition: json.hpp:5290
bool operator!=(const byte_container_with_subtype &rhs) const
Definition: json.hpp:5314
void clear_subtype() noexcept
clears the binary subtype
Definition: json.hpp:5343
byte_container_with_subtype() noexcept(noexcept(container_type()))
Definition: json.hpp:5280
byte_container_with_subtype(container_type &&b, subtype_type subtype_) noexcept(noexcept(container_type(std::move(b))))
Definition: json.hpp:5302
constexpr bool has_subtype() const noexcept
return whether the value has a subtype
Definition: json.hpp:5336
void set_subtype(subtype_type subtype_) noexcept
sets the binary subtype
Definition: json.hpp:5321
constexpr subtype_type subtype() const noexcept
return the binary subtype
Definition: json.hpp:5329
std::uint64_t subtype_type
Definition: json.hpp:5277
bool operator==(const byte_container_with_subtype &rhs) const
Definition: json.hpp:5308
deserialization of CBOR, MessagePack, and UBJSON values
Definition: json.hpp:8536
binary_reader & operator=(const binary_reader &)=delete
binary_reader(InputAdapterType &&adapter, const input_format_t format=input_format_t::json) noexcept
create a binary reader
Definition: json.hpp:8552
binary_reader & operator=(binary_reader &&)=default
binary_reader(const binary_reader &)=delete
bool sax_parse(const input_format_t format, json_sax_t *sax_, const bool strict=true, const cbor_tag_handler_t tag_handler=cbor_tag_handler_t::error)
Definition: json.hpp:8573
binary_reader(binary_reader &&)=default
serialization to CBOR and MessagePack values
Definition: json.hpp:14060
void write_ubjson(const BasicJsonType &j, const bool use_count, const bool use_type, const bool add_prefix=true, const bool use_bjdata=false)
Definition: json.hpp:14759
static constexpr CharType to_char_type(InputCharType x) noexcept
Definition: json.hpp:15844
binary_writer(output_adapter_t< CharType > adapter)
create a binary writer
Definition: json.hpp:14071
static CharType to_char_type(std::uint8_t x) noexcept
Definition: json.hpp:15822
void write_bson(const BasicJsonType &j)
Definition: json.hpp:14080
void write_cbor(const BasicJsonType &j)
Definition: json.hpp:14109
static constexpr CharType to_char_type(std::uint8_t x) noexcept
Definition: json.hpp:15815
void write_msgpack(const BasicJsonType &j)
Definition: json.hpp:14433
general exception of the basic_json class
Definition: json.hpp:3874
const int id
the id of the exception
Definition: json.hpp:3883
static std::string diagnostics(std::nullptr_t)
Definition: json.hpp:3894
static std::string diagnostics(const BasicJsonType *leaf_element)
Definition: json.hpp:3900
static std::string name(const std::string &ename, int id_)
Definition: json.hpp:3889
const char * what() const noexcept override
returns the explanatory string
Definition: json.hpp:3877
exception indicating errors with iterators
Definition: json.hpp:4025
static invalid_iterator create(int id_, const std::string &what_arg, BasicJsonContext context)
Definition: json.hpp:4028
a template for a bidirectional iterator for the basic_json class This class implements a both iterato...
Definition: json.hpp:12093
bool operator<(const iter_impl &other) const
comparison: smaller
Definition: json.hpp:12556
iter_impl operator-(difference_type i) const
subtract from iterator
Definition: json.hpp:12686
bool operator!=(const IterImpl &other) const
comparison: not equal
Definition: json.hpp:12547
void set_end() noexcept
set the iterator past the last value
Definition: json.hpp:12283
typename BasicJsonType::difference_type difference_type
a type to represent differences between iterators
Definition: json.hpp:12120
iter_impl & operator--()
pre-decrement (–it)
Definition: json.hpp:12470
difference_type operator-(const iter_impl &other) const
return difference
Definition: json.hpp:12697
iter_impl & operator=(const iter_impl< const BasicJsonType > &other) noexcept
converting assignment
Definition: json.hpp:12202
typename std::conditional< std::is_const< BasicJsonType >::value, typename BasicJsonType::const_reference, typename BasicJsonType::reference >::type reference
defines a reference to the type iterated over (value_type)
Definition: json.hpp:12129
reference operator*() const
return a reference to the value pointed to by the iterator
Definition: json.hpp:12322
iter_impl(iter_impl &&) noexcept=default
bool operator>=(const iter_impl &other) const
comparison: greater than or equal
Definition: json.hpp:12609
typename std::conditional< std::is_const< BasicJsonType >::value, typename BasicJsonType::const_pointer, typename BasicJsonType::pointer >::type pointer
defines a pointer to the type iterated over (value_type)
Definition: json.hpp:12124
iter_impl & operator=(const iter_impl< typename std::remove_const< BasicJsonType >::type > &other) noexcept
converting assignment
Definition: json.hpp:12227
pointer operator->() const
dereference the iterator
Definition: json.hpp:12366
iter_impl(const iter_impl< const BasicJsonType > &other) noexcept
const copy constructor
Definition: json.hpp:12192
iter_impl(const iter_impl< typename std::remove_const< BasicJsonType >::type > &other) noexcept
converting constructor
Definition: json.hpp:12217
internal_iterator< typename std::remove_const< BasicJsonType >::type > m_it
the actual iterator of the associated instance
Definition: json.hpp:12789
iter_impl operator+(difference_type i) const
add to iterator
Definition: json.hpp:12664
friend iter_impl operator+(difference_type i, const iter_impl &it)
addition of distance and iterator
Definition: json.hpp:12675
const object_t::key_type & key() const
return the key of an object iterator
Definition: json.hpp:12764
bool operator==(const IterImpl &other) const
comparison: equal
Definition: json.hpp:12511
bool operator>(const iter_impl &other) const
comparison: greater than
Definition: json.hpp:12600
typename BasicJsonType::value_type value_type
the type of the values when the iterator is dereferenced
Definition: json.hpp:12118
reference value() const
return the value of an iterator
Definition: json.hpp:12780
iter_impl & operator++()
pre-increment (++it)
Definition: json.hpp:12419
reference operator[](difference_type n) const
access to successor
Definition: json.hpp:12726
bool operator<=(const iter_impl &other) const
comparison: less than or equal
Definition: json.hpp:12591
iter_impl operator++(int) &
post-increment (it++)
Definition: json.hpp:12408
std::bidirectional_iterator_tag iterator_category
Definition: json.hpp:12115
iter_impl operator--(int) &
post-decrement (it–)
Definition: json.hpp:12459
iter_impl & operator+=(difference_type i)
add to iterator
Definition: json.hpp:12618
iter_impl & operator-=(difference_type i)
subtract from iterator
Definition: json.hpp:12655
Definition: json.hpp:4628
std::input_iterator_tag iterator_category
Definition: json.hpp:4634
typename std::remove_cv< typename std::remove_reference< decltype(std::declval< IteratorType >().key()) >::type >::type string_type
Definition: json.hpp:4635
iteration_proxy_value(IteratorType it) noexcept
Definition: json.hpp:4650
bool operator!=(const iteration_proxy_value &o) const
inequality operator (needed for range-based for)
Definition: json.hpp:4676
IteratorType::reference value() const
return value of the iterator
Definition: json.hpp:4718
iteration_proxy_value & operator++()
increment operator (needed for range-based for)
Definition: json.hpp:4661
iteration_proxy_value & operator*()
dereference operator (needed for range-based for)
Definition: json.hpp:4655
std::ptrdiff_t difference_type
Definition: json.hpp:4630
const string_type & key() const
return key of the iterator
Definition: json.hpp:4682
bool operator==(const iteration_proxy_value &o) const
equality operator (needed for InputIterator)
Definition: json.hpp:4670
proxy class for the items() function
Definition: json.hpp:4726
iteration_proxy_value< IteratorType > begin() noexcept
return iterator begin (needed for range-based for)
Definition: json.hpp:4737
iteration_proxy_value< IteratorType > end() noexcept
return iterator end (needed for range-based for)
Definition: json.hpp:4743
iteration_proxy(typename IteratorType::reference cont) noexcept
construct iteration proxy from a container
Definition: json.hpp:4733
Definition: json.hpp:13819
json_ref(json_ref &&) noexcept=default
value_type const & operator*() const
Definition: json.hpp:13858
BasicJsonType value_type
Definition: json.hpp:13821
json_ref(Args &&... args)
Definition: json.hpp:13838
json_ref(const value_type &value)
Definition: json.hpp:13827
value_type const * operator->() const
Definition: json.hpp:13863
json_ref(std::initializer_list< json_ref > init)
Definition: json.hpp:13831
json_ref(value_type &&value)
Definition: json.hpp:13823
value_type moved_or_copied() const
Definition: json.hpp:13849
a template for a reverse iterator class
Definition: json.hpp:12831
json_reverse_iterator(const typename base_iterator::iterator_type &it) noexcept
create reverse iterator from iterator
Definition: json.hpp:12840
typename Base::reference reference
the reference type for the pointed-to element
Definition: json.hpp:12837
json_reverse_iterator operator-(difference_type i) const
subtract from iterator
Definition: json.hpp:12883
json_reverse_iterator & operator+=(difference_type i)
add to iterator
Definition: json.hpp:12871
std::reverse_iterator< Base > base_iterator
shortcut to the reverse iterator adapter
Definition: json.hpp:12835
json_reverse_iterator(const base_iterator &it) noexcept
create reverse iterator from base class
Definition: json.hpp:12844
reference operator[](difference_type n) const
access to successor
Definition: json.hpp:12895
json_reverse_iterator operator--(int) &
post-decrement (it–)
Definition: json.hpp:12859
std::ptrdiff_t difference_type
Definition: json.hpp:12833
difference_type operator-(const json_reverse_iterator &other) const
return difference
Definition: json.hpp:12889
json_reverse_iterator operator+(difference_type i) const
add to iterator
Definition: json.hpp:12877
json_reverse_iterator operator++(int) &
post-increment (it++)
Definition: json.hpp:12847
auto key() const -> decltype(std::declval< Base >().key())
return the key of an object iterator
Definition: json.hpp:12901
json_reverse_iterator & operator--()
pre-decrement (–it)
Definition: json.hpp:12865
reference value() const
return the value of an iterator
Definition: json.hpp:12908
json_reverse_iterator & operator++()
pre-increment (++it)
Definition: json.hpp:12853
Definition: json.hpp:6634
bool end_array()
Definition: json.hpp:6697
bool start_object(std::size_t=static_cast< std::size_t >(-1))
Definition: json.hpp:6677
typename BasicJsonType::string_t string_t
Definition: json.hpp:6639
bool binary(binary_t &)
Definition: json.hpp:6672
bool boolean(bool)
Definition: json.hpp:6647
typename BasicJsonType::number_integer_t number_integer_t
Definition: json.hpp:6636
typename BasicJsonType::number_float_t number_float_t
Definition: json.hpp:6638
typename BasicJsonType::binary_t binary_t
Definition: json.hpp:6640
bool key(string_t &)
Definition: json.hpp:6682
bool end_object()
Definition: json.hpp:6687
bool start_array(std::size_t=static_cast< std::size_t >(-1))
Definition: json.hpp:6692
bool parse_error(std::size_t, const std::string &, const detail::exception &)
Definition: json.hpp:6702
bool number_integer(number_integer_t)
Definition: json.hpp:6652
bool string(string_t &)
Definition: json.hpp:6667
bool number_unsigned(number_unsigned_t)
Definition: json.hpp:6657
bool null()
Definition: json.hpp:6642
typename BasicJsonType::number_unsigned_t number_unsigned_t
Definition: json.hpp:6637
bool number_float(number_float_t, const string_t &)
Definition: json.hpp:6662
Definition: json.hpp:6327
typename BasicJsonType::string_t string_t
Definition: json.hpp:6332
json_sax_dom_callback_parser & operator=(const json_sax_dom_callback_parser &)=delete
bool start_object(std::size_t len)
Definition: json.hpp:6394
bool key(string_t &val)
Definition: json.hpp:6412
constexpr bool is_errored() const
Definition: json.hpp:6527
typename BasicJsonType::number_unsigned_t number_unsigned_t
Definition: json.hpp:6330
typename BasicJsonType::number_integer_t number_integer_t
Definition: json.hpp:6329
bool null()
Definition: json.hpp:6352
typename BasicJsonType::parser_callback_t parser_callback_t
Definition: json.hpp:6334
bool start_array(std::size_t len)
Definition: json.hpp:6465
~json_sax_dom_callback_parser()=default
json_sax_dom_callback_parser(const json_sax_dom_callback_parser &)=delete
typename BasicJsonType::binary_t binary_t
Definition: json.hpp:6333
bool binary(binary_t &val)
Definition: json.hpp:6388
bool number_integer(number_integer_t val)
Definition: json.hpp:6364
typename BasicJsonType::number_float_t number_float_t
Definition: json.hpp:6331
bool end_array()
Definition: json.hpp:6482
typename BasicJsonType::parse_event_t parse_event_t
Definition: json.hpp:6335
bool boolean(bool val)
Definition: json.hpp:6358
bool number_unsigned(number_unsigned_t val)
Definition: json.hpp:6370
json_sax_dom_callback_parser & operator=(json_sax_dom_callback_parser &&)=default
bool string(string_t &val)
Definition: json.hpp:6382
bool number_float(number_float_t val, const string_t &)
Definition: json.hpp:6376
bool end_object()
Definition: json.hpp:6429
json_sax_dom_callback_parser(json_sax_dom_callback_parser &&)=default
bool parse_error(std::size_t, const std::string &, const Exception &ex)
Definition: json.hpp:6515
json_sax_dom_callback_parser(BasicJsonType &r, const parser_callback_t cb, const bool allow_exceptions_=true)
Definition: json.hpp:6337
SAX implementation to create a JSON value from SAX events.
Definition: json.hpp:6153
bool start_array(std::size_t len)
Definition: json.hpp:6245
json_sax_dom_parser(const json_sax_dom_parser &)=delete
typename BasicJsonType::binary_t binary_t
Definition: json.hpp:6159
json_sax_dom_parser & operator=(json_sax_dom_parser &&)=default
bool number_unsigned(number_unsigned_t val)
Definition: json.hpp:6195
typename BasicJsonType::number_integer_t number_integer_t
Definition: json.hpp:6155
bool boolean(bool val)
Definition: json.hpp:6183
~json_sax_dom_parser()=default
bool parse_error(std::size_t, const std::string &, const Exception &ex)
Definition: json.hpp:6265
bool string(string_t &val)
Definition: json.hpp:6207
bool end_object()
Definition: json.hpp:6238
typename BasicJsonType::number_unsigned_t number_unsigned_t
Definition: json.hpp:6156
bool start_object(std::size_t len)
Definition: json.hpp:6219
bool null()
Definition: json.hpp:6177
bool binary(binary_t &val)
Definition: json.hpp:6213
constexpr bool is_errored() const
Definition: json.hpp:6277
bool key(string_t &val)
Definition: json.hpp:6231
json_sax_dom_parser(json_sax_dom_parser &&)=default
typename BasicJsonType::number_float_t number_float_t
Definition: json.hpp:6157
json_sax_dom_parser & operator=(const json_sax_dom_parser &)=delete
bool number_float(number_float_t val, const string_t &)
Definition: json.hpp:6201
bool end_array()
Definition: json.hpp:6257
json_sax_dom_parser(BasicJsonType &r, const bool allow_exceptions_=true)
Definition: json.hpp:6166
typename BasicJsonType::string_t string_t
Definition: json.hpp:6158
bool number_integer(number_integer_t val)
Definition: json.hpp:6189
Definition: json.hpp:6741
JSON_HEDLEY_RETURNS_NON_NULL static JSON_HEDLEY_CONST const char * token_type_name(const token_type t) noexcept
return name of values of type token_type (only used for errors)
Definition: json.hpp:6768
token_type
token types for the parser
Definition: json.hpp:6745
@ value_float
an floating point number – use get_number_float() for actual value
@ begin_array
the character for array begin [
@ value_string
a string – use get_string() for actual value
@ end_array
the character for array end ]
@ uninitialized
indicating the scanner is uninitialized
@ parse_error
indicating a parse error
@ value_integer
a signed integer – use get_number_integer() for actual value
@ value_separator
the value separator ,
@ end_object
the character for object end }
@ literal_true
the true literal
@ begin_object
the character for object begin {
@ value_unsigned
an unsigned integer – use get_number_unsigned() for actual value
@ literal_null
the null literal
@ end_of_input
indicating the end of the input buffer
@ name_separator
the name separator :
@ literal_or_value
a literal or the begin of a value (only for diagnostics)
@ literal_false
the false literal
lexical analysis
Definition: json.hpp:6818
string_t & get_string()
return current string value (implicitly resets the token; useful only once)
Definition: json.hpp:8136
token_type scan()
Definition: json.hpp:8215
void skip_whitespace()
Definition: json.hpp:8206
lexer & operator=(lexer &&)=default
bool skip_bom()
skip the UTF-8 byte order mark
Definition: json.hpp:8192
lexer(InputAdapterType &&adapter, bool ignore_comments_=false) noexcept
Definition: json.hpp:6829
constexpr position_t get_position() const noexcept
return position of last read token
Definition: json.hpp:8146
constexpr number_integer_t get_number_integer() const noexcept
return integer value
Definition: json.hpp:8118
typename lexer_base< BasicJsonType >::token_type token_type
Definition: json.hpp:6827
lexer & operator=(lexer &)=delete
lexer(const lexer &)=delete
constexpr number_unsigned_t get_number_unsigned() const noexcept
return unsigned integer value
Definition: json.hpp:8124
constexpr number_float_t get_number_float() const noexcept
return floating-point value
Definition: json.hpp:8130
std::string get_token_string() const
Definition: json.hpp:8154
JSON_HEDLEY_RETURNS_NON_NULL constexpr const char * get_error_message() const noexcept
return syntax error message
Definition: json.hpp:8179
exception indicating other library errors
Definition: json.hpp:4077
static other_error create(int id_, const std::string &what_arg, BasicJsonContext context)
Definition: json.hpp:4080
exception indicating access out of the defined range
Definition: json.hpp:4060
static out_of_range create(int id_, const std::string &what_arg, BasicJsonContext context)
Definition: json.hpp:4063
Definition: json.hpp:14019
output_adapter(std::basic_ostream< CharType > &s)
Definition: json.hpp:14026
output_adapter(std::vector< CharType, AllocatorType > &vec)
Definition: json.hpp:14022
output_adapter(StringType &s)
Definition: json.hpp:14030
output adapter for output streams
Definition: json.hpp:13971
void write_character(CharType c) override
Definition: json.hpp:13977
output_stream_adapter(std::basic_ostream< CharType > &s) noexcept
Definition: json.hpp:13973
output adapter for basic_string
Definition: json.hpp:13996
void write_character(CharType c) override
Definition: json.hpp:14002
output_string_adapter(StringType &s) noexcept
Definition: json.hpp:13998
output adapter for byte vectors
Definition: json.hpp:13946
output_vector_adapter(std::vector< CharType, AllocatorType > &vec) noexcept
Definition: json.hpp:13948
void write_character(CharType c) override
Definition: json.hpp:13952
exception indicating a parse error
Definition: json.hpp:3972
static parse_error create(int id_, const position_t &pos, const std::string &what_arg, BasicJsonContext context)
create a parse error exception
Definition: json.hpp:3984
static parse_error create(int id_, std::size_t byte_, const std::string &what_arg, BasicJsonContext context)
Definition: json.hpp:3992
const std::size_t byte
byte index of the parse error
Definition: json.hpp:4009
syntax analysis
Definition: json.hpp:11446
bool sax_parse(SAX *sax, const bool strict=true)
Definition: json.hpp:11546
parser(InputAdapterType &&adapter, const parser_callback_t< BasicJsonType > cb=nullptr, const bool allow_exceptions_=true, const bool skip_comments=false)
a parser reading from an input adapter
Definition: json.hpp:11456
bool accept(const bool strict=true)
public accept interface
Definition: json.hpp:11538
void parse(const bool strict, BasicJsonType &result)
public parser interface
Definition: json.hpp:11478
Definition: json.hpp:11920
primitive_iterator_t operator+(difference_type n) noexcept
Definition: json.hpp:11970
primitive_iterator_t & operator++() noexcept
Definition: json.hpp:11982
constexpr bool is_end() const noexcept
return whether the iterator is at end
Definition: json.hpp:11955
primitive_iterator_t & operator-=(difference_type n) noexcept
Definition: json.hpp:12014
constexpr bool is_begin() const noexcept
return whether the iterator can be dereferenced
Definition: json.hpp:11949
friend constexpr bool operator<(primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept
Definition: json.hpp:11965
primitive_iterator_t operator++(int) &noexcept
Definition: json.hpp:11988
void set_begin() noexcept
set iterator to a defined beginning
Definition: json.hpp:11937
friend constexpr bool operator==(primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept
Definition: json.hpp:11960
friend constexpr difference_type operator-(primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept
Definition: json.hpp:11977
primitive_iterator_t & operator--() noexcept
Definition: json.hpp:11995
void set_end() noexcept
set iterator to a defined past the end
Definition: json.hpp:11943
constexpr difference_type get_value() const noexcept
Definition: json.hpp:11931
primitive_iterator_t operator--(int) &noexcept
Definition: json.hpp:12001
primitive_iterator_t & operator+=(difference_type n) noexcept
Definition: json.hpp:12008
Definition: json.hpp:17023
const error_handler_t error_handler
error_handler how to react on decoding errors
Definition: json.hpp:17955
const std::lconv * loc
the locale
Definition: json.hpp:17940
std::array< char, 64 > number_buffer
a (hopefully) large enough character buffer
Definition: json.hpp:17937
serializer(serializer &&)=delete
serializer & operator=(serializer &&)=delete
const char decimal_point
the locale's decimal point character
Definition: json.hpp:17944
std::uint8_t state
Definition: json.hpp:17365
std::size_t bytes
Definition: json.hpp:17366
const char thousands_sep
the locale's thousand separator character
Definition: json.hpp:17942
serializer & operator=(const serializer &)=delete
std::size_t undumped_chars
Definition: json.hpp:17370
void dump(const BasicJsonType &val, const bool pretty_print, const bool ensure_ascii, const unsigned int indent_step, const unsigned int current_indent=0)
internal implementation of the serialization function
Definition: json.hpp:17078
const char indent_char
the indentation character
Definition: json.hpp:17950
std::size_t bytes_after_last_accept
Definition: json.hpp:17369
std::array< char, 512 > string_buffer
string buffer
Definition: json.hpp:17947
JSON_PRIVATE_UNLESS_TESTED const bool ensure_ascii
Definition: json.hpp:17363
serializer(output_adapter_t< char > s, const char ichar, error_handler_t error_handler_=error_handler_t::strict)
Definition: json.hpp:17038
serializer(const serializer &)=delete
string_t indent_string
the indentation string
Definition: json.hpp:17952
exception indicating executing a member function with a wrong type
Definition: json.hpp:4043
static type_error create(int id_, const std::string &what_arg, BasicJsonContext context)
Definition: json.hpp:4046
JSON Pointer defines a string syntax for identifying a specific value within a JSON document.
Definition: json.hpp:12950
friend json_pointer operator/(const json_pointer &lhs, string_t token)
create a new JSON pointer by appending the unescaped token at the end of the JSON pointer
Definition: json.hpp:13034
void pop_back()
remove last reference token
Definition: json.hpp:13062
friend json_pointer operator/(const json_pointer &lhs, std::size_t array_idx)
create a new JSON pointer by appending the array-index-token at the end of the JSON pointer
Definition: json.hpp:13041
json_pointer parent_pointer() const
returns the parent of this JSON pointer
Definition: json.hpp:13048
bool empty() const noexcept
return whether pointer points to the root document
Definition: json.hpp:13100
json_pointer & operator/=(std::size_t array_idx)
append an array index at the end of this JSON pointer
Definition: json.hpp:13019
void push_back(const string_t &token)
append an unescaped token at the end of the reference pointer
Definition: json.hpp:13086
typename string_t_helper< RefStringType >::type string_t
Definition: json.hpp:12972
json_pointer & operator/=(const json_pointer &ptr)
append another JSON pointer at the end of this JSON pointer
Definition: json.hpp:13001
friend json_pointer operator/(const json_pointer &lhs, const json_pointer &rhs)
create a new JSON pointer by appending the right JSON pointer at the end of the left JSON pointer
Definition: json.hpp:13026
friend class json_pointer
Definition: json.hpp:12956
string_t to_string() const
return a string representation of the JSON pointer
Definition: json.hpp:12982
friend bool operator==(json_pointer< RefStringTypeLhs > const &lhs, json_pointer< RefStringTypeRhs > const &rhs) noexcept
compares two JSON pointers for equality
Definition: json.hpp:13790
const string_t & back() const
return last reference token
Definition: json.hpp:13074
friend bool operator!=(json_pointer< RefStringTypeLhs > const &lhs, json_pointer< RefStringTypeRhs > const &rhs) noexcept
compares two JSON pointers for inequality
Definition: json.hpp:13797
json_pointer & operator/=(string_t token)
append an unescaped reference token at the end of this JSON pointer
Definition: json.hpp:13011
json_pointer(const string_t &s="")
create JSON pointer
Definition: json.hpp:12976
void push_back(string_t &&token)
append an unescaped token at the end of the reference pointer
Definition: json.hpp:13093
decltype(get< N >(std::declval< ::nlohmann::detail::iteration_proxy_value< IteratorType > >())) type
Definition: json.hpp:4788
#define NLOHMANN_BASIC_JSON_TPL_DECLARATION
Definition: json.hpp:2508
#define JSON_HEDLEY_CONST
Definition: json.hpp:1687
#define JSON_HEDLEY_DIAGNOSTIC_PUSH
Definition: json.hpp:971
#define JSON_HEDLEY_WARN_UNUSED_RESULT
Definition: json.hpp:1317
#define JSON_PRIVATE_UNLESS_TESTED
Definition: json.hpp:2471
#define NLOHMANN_JSON_VERSION_PATCH
Definition: json.hpp:52
#define JSON_HEDLEY_LIKELY(expr)
Definition: json.hpp:1582
#define JSON_HEDLEY_NON_NULL(...)
Definition: json.hpp:1475
#define JSON_INTERNAL_CATCH(exception)
Definition: json.hpp:2438
#define JSON_HEDLEY_RETURNS_NON_NULL
Definition: json.hpp:1916
#define JSON_CATCH(exception)
Definition: json.hpp:2437
#define JSON_ASSERT(x)
Definition: json.hpp:2464
#define JSON_THROW(exception)
Definition: json.hpp:2435
#define NLOHMANN_JSON_VERSION_MAJOR
Definition: json.hpp:50
#define NLOHMANN_BASIC_JSON_TPL
Definition: json.hpp:2517
#define JSON_HEDLEY_UNLIKELY(expr)
Definition: json.hpp:1583
#define JSON_TRY
Definition: json.hpp:2436
#define JSON_NO_UNIQUE_ADDRESS
Definition: json.hpp:2417
#define NLOHMANN_JSON_VERSION_MINOR
Definition: json.hpp:51
#define JSON_HEDLEY_DIAGNOSTIC_POP
Definition: json.hpp:972
#define JSON_EXPLICIT
Definition: json.hpp:2729
#define JSON_HEDLEY_PURE
Definition: json.hpp:1656
void grisu2(char *buf, int &len, int &decimal_exponent, diyfp m_minus, diyfp v, diyfp m_plus)
Definition: json.hpp:16698
JSON_HEDLEY_RETURNS_NON_NULL char * format_buffer(char *buf, int len, int decimal_exponent, int min_exp, int max_exp)
prettify v = buf * 10^decimal_exponent
Definition: json.hpp:16850
Target reinterpret_bits(const Source source)
Definition: json.hpp:15918
boundaries compute_boundaries(FloatType value)
Definition: json.hpp:16059
int find_largest_pow10(const std::uint32_t n, std::uint32_t &pow10)
Definition: json.hpp:16362
constexpr int kGamma
Definition: json.hpp:16182
void grisu2_round(char *buf, int len, std::uint64_t dist, std::uint64_t delta, std::uint64_t rest, std::uint64_t ten_k)
Definition: json.hpp:16416
JSON_HEDLEY_RETURNS_NON_NULL char * append_exponent(char *buf, int e)
appends a decimal representation of e to buf
Definition: json.hpp:16798
void grisu2_digit_gen(char *buffer, int &length, int &decimal_exponent, diyfp M_minus, diyfp w, diyfp M_plus)
Definition: json.hpp:16457
constexpr int kAlpha
Definition: json.hpp:16181
cached_power get_cached_power_for_binary_exponent(int e)
Definition: json.hpp:16198
detail namespace with internal helper functions
Definition: json.hpp:109
typename std::enable_if< B, T >::type enable_if_t
Definition: json.hpp:2862
typename T::reference reference_t
Definition: json.hpp:3225
decltype(std::declval< StringType & >().append(std::declval< const Arg & >().data(), std::declval< const Arg & >().size())) string_can_append_data
Definition: json.hpp:3788
bool operator<(const value_t lhs, const value_t rhs) noexcept
comparison operator for JSON types
Definition: json.hpp:165
typename actual_object_comparator< BasicJsonType >::type actual_object_comparator_t
Definition: json.hpp:3310
typename T::key_compare detect_key_compare
Definition: json.hpp:3294
decltype(T::from_json(std::declval< Args >()...)) from_json_function
Definition: json.hpp:3234
is_detected< string_can_append_iter, StringType, Arg > detect_string_can_append_iter
Definition: json.hpp:3785
void to_json(BasicJsonType &j, T b) noexcept
Definition: json.hpp:5054
value_type_t< iterator_traits< iterator_t< T > > > range_value_t
Definition: json.hpp:3406
value_t
the JSON type enumeration
Definition: json.hpp:139
@ number_integer
number value (signed integer)
@ discarded
discarded by the parser callback function
@ binary
binary array (ordered collection of bytes)
@ object
object (unordered set of name/value pairs)
@ number_float
number value (floating-point)
@ number_unsigned
number value (unsigned integer)
@ array
array (ordered collection of values)
void from_json(const BasicJsonType &j, typename std::nullptr_t &n)
Definition: json.hpp:4136
make_index_sequence< sizeof...(Ts)> index_sequence_for
Definition: json.hpp:2966
decltype(std::declval< T & >().parse_error(std::declval< std::size_t >(), std::declval< const std::string & >(), std::declval< const Exception & >())) parse_error_function_t
Definition: json.hpp:8405
typename T::pointer pointer_t
Definition: json.hpp:3222
decltype(std::declval< T & >().string(std::declval< String & >())) string_function_t
Definition: json.hpp:8378
is_detected< string_can_append, StringType, Arg > detect_string_can_append
Definition: json.hpp:3773
std::function< bool(int, parse_event_t, BasicJsonType &)> parser_callback_t
Definition: json.hpp:11437
typename T::difference_type difference_type_t
Definition: json.hpp:3219
typename detector< nonesuch, void, Op, Args... >::type detected_t
Definition: json.hpp:2294
void int_to_string(string_type &target, std::size_t value)
Definition: json.hpp:4621
void from_json_array_impl(const BasicJsonType &j, typename BasicJsonType::array_t &arr, priority_tag< 3 >)
Definition: json.hpp:4290
integer_sequence< size_t, Ints... > index_sequence
Definition: json.hpp:2904
decltype(std::declval< T & >().key(std::declval< String & >())) key_function_t
Definition: json.hpp:8390
decltype(std::declval< T & >().boolean(std::declval< bool >())) boolean_function_t
Definition: json.hpp:8362
decltype(std::declval< T & >().binary(std::declval< Binary & >())) binary_function_t
Definition: json.hpp:8382
decltype(std::declval< T & >().number_integer(std::declval< Integer >())) number_integer_function_t
Definition: json.hpp:8366
JSON_HEDLEY_RETURNS_NON_NULL char * to_chars(char *first, const char *last, FloatType value)
generates a decimal representation of the floating-point number value in [first, last).
Definition: json.hpp:16935
typename std::conditional< is_key_type_comparable< BasicJsonType, KeyTypeCVRef >::value &&!(ExcludeObjectKeyType &&std::is_same< KeyType, typename BasicJsonType::object_t::key_type >::value) &&(!RequireTransparentComparator||is_detected< detect_is_transparent, typename BasicJsonType::object_comparator_t >::value) &&!is_json_iterator_of< BasicJsonType, KeyType >::value &&!is_json_pointer< KeyType >::value, std::true_type, std::false_type >::type is_usable_as_key_type
Definition: json.hpp:3670
void to_json_tuple_impl(BasicJsonType &j, const Tuple &t, index_sequence< Idx... >)
Definition: json.hpp:5177
enable_if_t< is_range< R >::value, result_of_begin< decltype(std::declval< R & >())> > iterator_t
Definition: json.hpp:3403
std::is_convertible< detected_t< Op, Args... >, To > is_detected_convertible
Definition: json.hpp:2307
typename std::remove_cv< typename std::remove_reference< T >::type >::type uncvref_t
Definition: json.hpp:2848
decltype(std::declval< StringType & >().append(std::declval< Arg && >())) string_can_append
Definition: json.hpp:3770
cbor_tag_handler_t
how to treat CBOR tags
Definition: json.hpp:8508
@ store
store tags as binary type
@ error
throw a parse_error exception in case of a tag
parse_event_t
Definition: json.hpp:11420
@ value
the parser finished reading a JSON value
@ key
the parser read a key of a value in an object
@ array_end
the parser read ] and finished processing a JSON array
@ array_start
the parser read [ and started to process a JSON array
@ object_start
the parser read { and started to process a JSON object
@ object_end
the parser read } and finished processing a JSON object
error_handler_t
how to treat decoding errors
Definition: json.hpp:17015
@ strict
throw a type_error exception in case of invalid UTF-8
@ ignore
ignore invalid UTF-8 sequences
@ replace
replace invalid UTF-8 sequences with U+FFFD
decltype(std::declval< T & >().start_object(std::declval< std::size_t >())) start_object_function_t
Definition: json.hpp:8386
iterator_input_adapter_factory< IteratorType >::adapter_type input_adapter(IteratorType first, IteratorType last)
Definition: json.hpp:5881
typename std::conditional< is_detected< detect_erase_with_key_type, typename BasicJsonType::object_t, KeyType >::value, std::true_type, std::false_type >::type has_erase_with_key_type
Definition: json.hpp:3682
typename T::key_type key_type_t
Definition: json.hpp:3213
std::size_t combine(std::size_t seed, std::size_t h) noexcept
Definition: json.hpp:5380
std::size_t hash(const BasicJsonType &j)
hash a JSON value
Definition: json.hpp:5398
StringType escape(StringType s)
string escaping as described in RFC 6901 (Sect. 4)
Definition: json.hpp:2777
typename utility_internal::Gen< T, N >::type make_integer_sequence
Definition: json.hpp:2950
decltype(std::declval< T & >().number_unsigned(std::declval< Unsigned >())) number_unsigned_function_t
Definition: json.hpp:8370
std::is_same< Expected, detected_t< Op, Args... > > is_detected_exact
Definition: json.hpp:2303
typename detected_or< Default, Op, Args... >::type detected_or_t
Definition: json.hpp:2300
decltype(std::declval< T & >().start_array(std::declval< std::size_t >())) start_array_function_t
Definition: json.hpp:8397
std::pair< A1, A2 > from_json_tuple_impl(BasicJsonType &&j, identity_tag< std::pair< A1, A2 > >, priority_tag< 0 >)
Definition: json.hpp:4479
void concat_into(OutStringType &)
Definition: json.hpp:3766
void get_arithmetic_value(const BasicJsonType &j, ArithmeticType &val)
Definition: json.hpp:4150
void replace_substring(StringType &s, const StringType &f, const StringType &t)
replace all occurrences of a substring by another string
Definition: json.hpp:2758
typename detector< nonesuch, void, Op, Args... >::value_t is_detected
Definition: json.hpp:2288
is_detected< string_can_append_data, StringType, Arg > detect_string_can_append_data
Definition: json.hpp:3791
typename make_void< Ts... >::type void_t
Definition: json.hpp:2250
OutStringType concat(Args &&... args)
Definition: json.hpp:3850
make_integer_sequence< size_t, N > make_index_sequence
Definition: json.hpp:2958
std::shared_ptr< output_adapter_protocol< CharType > > output_adapter_t
a type to simplify interfaces
Definition: json.hpp:13941
typename T::mapped_type mapped_type_t
Definition: json.hpp:3210
input_format_t
the supported input formats
Definition: json.hpp:5535
void to_json(BasicJsonType &j, const T &b)
Definition: json.hpp:5171
std::tuple< Args... > from_json_tuple_impl_base(BasicJsonType &&j, index_sequence< Idx... >)
Definition: json.hpp:4473
decltype(std::declval< T >().template get< U >()) get_template_function
Definition: json.hpp:3237
decltype(std::declval< ObjectType & >().erase(std::declval< KeyType >())) detect_erase_with_key_type
Definition: json.hpp:3673
std::array< T, sizeof...(Idx)> from_json_inplace_array_impl(BasicJsonType &&j, identity_tag< std::array< T, sizeof...(Idx)> >, index_sequence< Idx... >)
Definition: json.hpp:4373
decltype(std::declval< StringType & >().append(std::declval< const Arg & >().begin(), std::declval< const Arg & >().end())) string_can_append_iter
Definition: json.hpp:3782
decltype(input_adapter(std::declval< const char * >(), std::declval< const char * >())) contiguous_bytes_input_adapter
Definition: json.hpp:5938
typename T::is_transparent detect_is_transparent
Definition: json.hpp:3650
decltype(std::declval< T & >().null()) null_function_t
Definition: json.hpp:8358
typename is_comparable< typename BasicJsonType::object_comparator_t, const key_type_t< typename BasicJsonType::object_t > &, KeyType >::type is_key_type_comparable
Definition: json.hpp:3647
auto get(const nlohmann::detail::iteration_proxy_value< IteratorType > &i) -> decltype(i.key())
Definition: json.hpp:4752
typename T::iterator_category iterator_category_t
Definition: json.hpp:3228
decltype(std::declval< T & >().number_float(std::declval< Float >(), std::declval< const String & >())) number_float_function_t
Definition: json.hpp:8374
std::size_t concat_length()
Definition: json.hpp:3735
is_detected< string_can_append_op, StringType, Arg > detect_string_can_append_op
Definition: json.hpp:3779
decltype(std::declval< StringType & >()+=std::declval< Arg && >()) string_can_append_op
Definition: json.hpp:3776
decltype(std::declval< T & >().end_array()) end_array_function_t
Definition: json.hpp:8400
void from_json(const BasicJsonType &j, std::unordered_map< Key, Value, Hash, KeyEqual, Allocator > &m)
Definition: json.hpp:4538
decltype(std::declval< T & >().end_object()) end_object_function_t
Definition: json.hpp:8393
T conditional_static_cast(U value)
Definition: json.hpp:3704
decltype(T::to_json(std::declval< Args >()...)) to_json_function
Definition: json.hpp:3231
typename T::value_type value_type_t
Definition: json.hpp:3216
namespace for Niels Lohmann
Definition: json.hpp:107
NLOHMANN_BASIC_JSON_TPL_DECLARATION std::string to_string(const NLOHMANN_BASIC_JSON_TPL &j)
user-defined to_string function for JSON values
Definition: json.hpp:23133
NLOHMANN_CAN_CALL_STD_FUNC_IMPL(begin)
bool operator!=(json_pointer< RefStringTypeLhs > const &lhs, json_pointer< RefStringTypeRhs > const &rhs) noexcept
Definition: json.hpp:13797
bool operator==(json_pointer< RefStringTypeLhs > const &lhs, json_pointer< RefStringTypeRhs > const &rhs) noexcept
Definition: json.hpp:13790
Definition: json.hpp:4772
NLOHMANN_BASIC_JSON_TPL_DECLARATION void swap(nlohmann::NLOHMANN_BASIC_JSON_TPL &j1, nlohmann::NLOHMANN_BASIC_JSON_TPL &j2) noexcept(//NOLINT(readability-inconsistent-declaration-parameter-name) is_nothrow_move_constructible< nlohmann::NLOHMANN_BASIC_JSON_TPL >::value &&//NOLINT(misc-redundant-expression) is_nothrow_move_assignable< nlohmann::NLOHMANN_BASIC_JSON_TPL >::value)
exchanges the values of two JSON objects
Definition: json.hpp:23179
default JSONSerializer template argument
Definition: json.hpp:5227
static auto from_json(BasicJsonType &&j, TargetType &val) noexcept(noexcept(::nlohmann::from_json(std::forward< BasicJsonType >(j), val))) -> decltype(::nlohmann::from_json(std::forward< BasicJsonType >(j), val), void())
convert a JSON value to any value type
Definition: json.hpp:5231
static auto from_json(BasicJsonType &&j) noexcept(noexcept(::nlohmann::from_json(std::forward< BasicJsonType >(j), detail::identity_tag< TargetType > {}))) -> decltype(::nlohmann::from_json(std::forward< BasicJsonType >(j), detail::identity_tag< TargetType > {}))
convert a JSON value to any value type
Definition: json.hpp:5241
static auto to_json(BasicJsonType &j, TargetType &&val) noexcept(noexcept(::nlohmann::to_json(j, std::forward< TargetType >(val)))) -> decltype(::nlohmann::to_json(j, std::forward< TargetType >(val)), void())
convert any value type to a JSON value
Definition: json.hpp:5251
Definition: json.hpp:3302
typename BasicJsonType::default_object_comparator_t object_comparator_t
Definition: json.hpp:3304
typename std::conditional< has_key_compare< object_t >::value, typename object_t::key_compare, object_comparator_t >::type type
Definition: json.hpp:3306
typename BasicJsonType::object_t object_t
Definition: json.hpp:3303
Definition: json.hpp:3318
Definition: json.hpp:3317
Op< Args... > type
Definition: json.hpp:2284
std::true_type value_t
Definition: json.hpp:2283
Definition: json.hpp:2275
Default type
Definition: json.hpp:2277
std::false_type value_t
Definition: json.hpp:2276
Definition: json.hpp:16046
diyfp plus
Definition: json.hpp:16049
diyfp w
Definition: json.hpp:16047
diyfp minus
Definition: json.hpp:16048
Definition: json.hpp:16185
std::uint64_t f
Definition: json.hpp:16186
int k
Definition: json.hpp:16188
int e
Definition: json.hpp:16187
Definition: json.hpp:15928
static constexpr int kPrecision
Definition: json.hpp:15929
static diyfp normalize(diyfp x) noexcept
normalize x such that the significand is >= 2^(q-1)
Definition: json.hpp:16017
static diyfp normalize_to(const diyfp &x, const int target_exponent) noexcept
normalize x such that the result has the exponent E
Definition: json.hpp:16034
static diyfp mul(const diyfp &x, const diyfp &y) noexcept
returns x * y
Definition: json.hpp:15952
constexpr diyfp(std::uint64_t f_, int e_) noexcept
Definition: json.hpp:15934
int e
Definition: json.hpp:15932
std::uint64_t f
Definition: json.hpp:15931
static diyfp sub(const diyfp &x, const diyfp &y) noexcept
returns x - y
Definition: json.hpp:15940
static void construct(BasicJsonType &j, const CompatibleArrayType &arr)
Definition: json.hpp:4966
static void construct(BasicJsonType &j, const std::valarray< T > &arr)
Definition: json.hpp:4995
static void construct(BasicJsonType &j, const std::vector< bool > &arr)
Definition: json.hpp:4979
static void construct(BasicJsonType &j, typename BasicJsonType::array_t &&arr)
Definition: json.hpp:4954
static void construct(BasicJsonType &j, const typename BasicJsonType::array_t &arr)
Definition: json.hpp:4944
static void construct(BasicJsonType &j, const typename BasicJsonType::binary_t &b)
Definition: json.hpp:4883
static void construct(BasicJsonType &j, typename BasicJsonType::binary_t &&b)
Definition: json.hpp:4892
static void construct(BasicJsonType &j, typename BasicJsonType::boolean_t b) noexcept
Definition: json.hpp:4837
static void construct(BasicJsonType &j, typename BasicJsonType::number_float_t val) noexcept
Definition: json.hpp:4905
static void construct(BasicJsonType &j, typename BasicJsonType::number_integer_t val) noexcept
Definition: json.hpp:4931
static void construct(BasicJsonType &j, typename BasicJsonType::number_unsigned_t val) noexcept
Definition: json.hpp:4918
static void construct(BasicJsonType &j, typename BasicJsonType::object_t &&obj)
Definition: json.hpp:5024
static void construct(BasicJsonType &j, const typename BasicJsonType::object_t &obj)
Definition: json.hpp:5014
static void construct(BasicJsonType &j, const CompatibleObjectType &obj)
Definition: json.hpp:5035
static void construct(BasicJsonType &j, typename BasicJsonType::string_t &&s)
Definition: json.hpp:4859
static void construct(BasicJsonType &j, const CompatibleStringType &str)
Definition: json.hpp:4870
static void construct(BasicJsonType &j, const typename BasicJsonType::string_t &s)
Definition: json.hpp:4850
Definition: json.hpp:4831
Definition: json.hpp:4568
auto operator()(const BasicJsonType &j, T &&val) const noexcept(noexcept(from_json(j, std::forward< T >(val)))) -> decltype(from_json(j, std::forward< T >(val)))
Definition: json.hpp:4570
typename BasicJsonType::template json_serializer< T, void > serializer
Definition: json.hpp:3256
Definition: json.hpp:3241
Definition: json.hpp:3297
typename BasicJsonType::template json_serializer< T, void > serializer
Definition: json.hpp:3271
Definition: json.hpp:3266
typename BasicJsonType::template json_serializer< T, void > serializer
Definition: json.hpp:3286
Definition: json.hpp:3281
Definition: json.hpp:4106
Definition: json.hpp:2890
T value_type
Definition: json.hpp:2891
static constexpr std::size_t size() noexcept
Definition: json.hpp:2892
an iterator value
Definition: json.hpp:12035
primitive_iterator_t primitive_iterator
generic iterator for all other types
Definition: json.hpp:12041
BasicJsonType::array_t::iterator array_iterator
iterator for JSON arrays
Definition: json.hpp:12039
BasicJsonType::object_t::iterator object_iterator
iterator for JSON objects
Definition: json.hpp:12037
Definition: json.hpp:3190
Definition: json.hpp:3177
Definition: json.hpp:3634
Definition: json.hpp:3498
Definition: json.hpp:3517
std::numeric_limits< CompatibleNumberIntegerType > CompatibleLimits
Definition: json.hpp:3576
std::numeric_limits< RealIntegerType > RealLimits
Definition: json.hpp:3575
Definition: json.hpp:3565
Definition: json.hpp:3588
typename BasicJsonType::object_t object_t
Definition: json.hpp:3428
Definition: json.hpp:3420
Definition: json.hpp:3440
Definition: json.hpp:3477
static constexpr auto value
Definition: json.hpp:3478
Definition: json.hpp:3591
Definition: json.hpp:3604
Definition: json.hpp:3413
nlohmann::detail::is_constructible_array_type_impl< BasicJsonType, ConstructibleArrayType, enable_if_t< !std::is_same< ConstructibleArrayType, typename BasicJsonType::value_type >::value &&!is_compatible_string_type< BasicJsonType, ConstructibleArrayType >::value &&is_default_constructible< ConstructibleArrayType >::value &&(std::is_move_assignable< ConstructibleArrayType >::value||std::is_copy_assignable< ConstructibleArrayType >::value)&&is_detected< iterator_t, ConstructibleArrayType >::value &&is_iterator_traits< iterator_traits< detected_t< iterator_t, ConstructibleArrayType > > >::value &&is_detected< range_value_t, ConstructibleArrayType >::value &&!std::is_same< ConstructibleArrayType, detected_t< range_value_t, ConstructibleArrayType > >::value &&is_complete_type< detected_t< range_value_t, ConstructibleArrayType > >::value > >::value_type range_value_t< ConstructibleArrayType > value_type
Definition: json.hpp:3547
Definition: json.hpp:3520
Definition: json.hpp:3561
typename BasicJsonType::object_t object_t
Definition: json.hpp:3452
Definition: json.hpp:3444
Definition: json.hpp:3473
Definition: json.hpp:3484
static constexpr auto value
Definition: json.hpp:3492
ConstructibleStringType laundered_type
Definition: json.hpp:3489
Definition: json.hpp:3607
Definition: json.hpp:3350
Definition: json.hpp:3330
Definition: json.hpp:2291
Definition: json.hpp:3249
static constexpr bool value
Definition: json.hpp:3250
Definition: json.hpp:5857
typename std::iterator_traits< T >::value_type value_type
Definition: json.hpp:5858
Definition: json.hpp:3366
Definition: json.hpp:3613
Definition: json.hpp:3200
Definition: json.hpp:3692
char x[2]
Definition: json.hpp:3693
Definition: json.hpp:3688
@ value
Definition: json.hpp:3699
char one
Definition: json.hpp:3689
static one test(decltype(&C::capacity))
Definition: json.hpp:3385
static constexpr bool value
Definition: json.hpp:3399
Definition: json.hpp:8440
Definition: json.hpp:8409
static constexpr bool value
Definition: json.hpp:8422
Definition: json.hpp:3624
T & reference
Definition: json.hpp:3054
T * pointer
Definition: json.hpp:3053
T value_type
Definition: json.hpp:3051
std::random_access_iterator_tag iterator_category
Definition: json.hpp:3050
ptrdiff_t difference_type
Definition: json.hpp:3052
Definition: json.hpp:3038
typename It::difference_type difference_type
Definition: json.hpp:3027
typename It::reference reference
Definition: json.hpp:3030
typename It::iterator_category iterator_category
Definition: json.hpp:3031
typename It::pointer pointer
Definition: json.hpp:3029
typename It::value_type value_type
Definition: json.hpp:3028
Definition: json.hpp:3019
Definition: json.hpp:2247
void type
Definition: json.hpp:2248
Definition: json.hpp:3324
Definition: json.hpp:2261
nonesuch(nonesuch const &)=delete
void operator=(nonesuch &&)=delete
nonesuch(nonesuch const &&)=delete
void operator=(nonesuch const &)=delete
abstract output adapter interface
Definition: json.hpp:13927
virtual void write_characters(const CharType *s, std::size_t length)=0
virtual void write_character(CharType c)=0
output_adapter_protocol(output_adapter_protocol &&) noexcept=default
virtual ~output_adapter_protocol()=default
output_adapter_protocol(const output_adapter_protocol &)=default
output_adapter_protocol()=default
struct to capture the start position of the current token
Definition: json.hpp:2812
std::size_t lines_read
the number of lines read
Definition: json.hpp:2818
std::size_t chars_read_current_line
the number of characters read in the current line
Definition: json.hpp:2816
std::size_t chars_read_total
the total number of characters read
Definition: json.hpp:2814
Definition: json.hpp:2974
Definition: json.hpp:2973
Definition: json.hpp:2979
static constexpr T value
Definition: json.hpp:2980
Definition: json.hpp:5197
auto operator()(BasicJsonType &j, T &&val) const noexcept(noexcept(to_json(j, std::forward< T >(val)))) -> decltype(to_json(j, std::forward< T >(val)), void())
Definition: json.hpp:5199
Definition: json.hpp:2910
Definition: json.hpp:2929
typename Extend< typename Gen< T, N/2 >::type, N/2, N % 2 >::type type
Definition: json.hpp:2931
SAX interface.
Definition: json.hpp:6022
virtual bool start_object(std::size_t elements)=0
the beginning of an object was read
virtual bool string(string_t &val)=0
a string value was read
virtual bool null()=0
a null value was read
typename BasicJsonType::number_integer_t number_integer_t
Definition: json.hpp:6023
typename BasicJsonType::binary_t binary_t
Definition: json.hpp:6027
virtual bool end_array()=0
the end of an array was read
virtual bool key(string_t &val)=0
an object key was read
typename BasicJsonType::number_unsigned_t number_unsigned_t
Definition: json.hpp:6024
virtual bool binary(binary_t &val)=0
a binary value was read
typename BasicJsonType::number_float_t number_float_t
Definition: json.hpp:6025
virtual bool start_array(std::size_t elements)=0
the beginning of an array was read
virtual bool parse_error(std::size_t position, const std::string &last_token, const detail::exception &ex)=0
a parse error occurred
json_sax(json_sax &&) noexcept=default
virtual bool boolean(bool val)=0
a boolean value was read
json_sax(const json_sax &)=default
virtual bool end_object()=0
the end of an object was read
virtual bool number_unsigned(number_unsigned_t val)=0
an unsigned integer number was read
typename BasicJsonType::string_t string_t
Definition: json.hpp:6026
virtual bool number_float(number_float_t val, const string_t &s)=0
a floating-point number was read
virtual bool number_integer(number_integer_t val)=0
an integer number was read
a minimal map-like container that preserves insertion order
Definition: json.hpp:17987
T & at(const Key &key)
Definition: json.hpp:18034
std::vector< std::pair< const Key, T >, Allocator > Container
Definition: json.hpp:17990
T mapped_type
Definition: json.hpp:17989
const T & at(const Key &key) const
Definition: json.hpp:18047
iterator find(const Key &key)
Definition: json.hpp:18144
iterator erase(iterator pos)
Definition: json.hpp:18079
void insert(InputIt first, InputIt last)
Definition: json.hpp:18191
std::pair< iterator, bool > insert(value_type &&value)
Definition: json.hpp:18168
const_iterator find(const Key &key) const
Definition: json.hpp:18156
Key key_type
Definition: json.hpp:17988
size_type erase(const Key &key)
Definition: json.hpp:18060
T & operator[](const Key &key)
Definition: json.hpp:18024
iterator erase(iterator first, iterator last)
Definition: json.hpp:18084
typename Container::const_iterator const_iterator
Definition: json.hpp:17992
typename std::enable_if< std::is_convertible< typename std::iterator_traits< InputIt >::iterator_category, std::input_iterator_tag >::value >::type require_input_iter
Definition: json.hpp:18188
ordered_map(It first, It last, const Allocator &alloc=Allocator())
Definition: json.hpp:18006
std::equal_to< Key > key_compare
Definition: json.hpp:17998
ordered_map(const Allocator &alloc) noexcept(noexcept(Container(alloc)))
Definition: json.hpp:18004
std::pair< iterator, bool > insert(const value_type &value)
Definition: json.hpp:18173
typename Container::size_type size_type
Definition: json.hpp:17993
typename Container::value_type value_type
Definition: json.hpp:17994
ordered_map(std::initializer_list< value_type > init, const Allocator &alloc=Allocator())
Definition: json.hpp:18008
ordered_map() noexcept(noexcept(Container()))
Definition: json.hpp:18003
size_type count(const Key &key) const
Definition: json.hpp:18132
typename Container::iterator iterator
Definition: json.hpp:17991
std::pair< iterator, bool > emplace(const key_type &key, T &&t)
Definition: json.hpp:18011
const T & operator[](const Key &key) const
Definition: json.hpp:18029
std::size_t operator()(const nlohmann::NLOHMANN_BASIC_JSON_TPL &j) const
Definition: json.hpp:23152
bool operator()(nlohmann::detail::value_t lhs, nlohmann::detail::value_t rhs) const noexcept
compare two value_t enum values
Definition: json.hpp:23166